Skip to content

Commit e7b46cb

Browse files
committed
Remove ModeHandler.createUndoPointForBrackets(). Fixes #9649.
It's not clear this is doing anything useful, but it's definitely causing performance issues in large files. Let's rip it out and see if anyone yells.
1 parent 58f625e commit e7b46cb

File tree

1 file changed

+1
-43
lines changed

1 file changed

+1
-43
lines changed

src/mode/modeHandler.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
851851
}
852852
}
853853

854-
ranRepeatableAction =
855-
(ranRepeatableAction && this.vimState.currentMode === Mode.Normal) ||
856-
this.createUndoPointForBrackets();
854+
ranRepeatableAction &&= this.vimState.currentMode === Mode.Normal;
857855

858856
// We don't want to record a repeatable action when exiting from these modes
859857
// by pressing <Esc>
@@ -1751,46 +1749,6 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
17511749
}
17521750
}
17531751

1754-
// Return true if a new undo point should be created based on brackets and parentheses
1755-
private createUndoPointForBrackets(): boolean {
1756-
// }])> keys all start a new undo state when directly next to an {[(< opening character
1757-
const key =
1758-
this.vimState.recordedState.actionKeys[this.vimState.recordedState.actionKeys.length - 1];
1759-
1760-
if (key === undefined) {
1761-
return false;
1762-
}
1763-
1764-
if (this.vimState.currentMode === Mode.Insert) {
1765-
// Check if the keypress is a closing bracket to a corresponding opening bracket right next to it
1766-
let result = PairMatcher.nextPairedChar(
1767-
this.vimState.cursorStopPosition,
1768-
key,
1769-
this.vimState,
1770-
false,
1771-
);
1772-
if (result !== undefined) {
1773-
if (this.vimState.cursorStopPosition.isEqual(result)) {
1774-
return true;
1775-
}
1776-
}
1777-
1778-
result = PairMatcher.nextPairedChar(
1779-
this.vimState.cursorStopPosition.getLeft(),
1780-
key,
1781-
this.vimState,
1782-
false,
1783-
);
1784-
if (result !== undefined) {
1785-
if (this.vimState.cursorStopPosition.getLeft(2).isEqual(result)) {
1786-
return true;
1787-
}
1788-
}
1789-
}
1790-
1791-
return false;
1792-
}
1793-
17941752
dispose() {
17951753
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
17961754
this.disposables.map((d) => d.dispose());

0 commit comments

Comments
 (0)