Skip to content

Commit 9091da0

Browse files
committed
Make VimState.isMultiCursor a function
I can't see any reason why this would be incorrect, and if it does break something, that something is wrong and should be fixed - there's no reason to maintain this information manually.
1 parent 458fd32 commit 9091da0

File tree

4 files changed

+3
-17
lines changed

4 files changed

+3
-17
lines changed

src/actions/commands/actions.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,6 @@ class CommandEsc extends BaseCommand {
436436
]);
437437

438438
return;
439-
} else {
440-
vimState.isMultiCursor = false;
441439
}
442440
}
443441

@@ -1615,7 +1613,6 @@ class CommandInsertNewLineAbove extends BaseCommand {
16151613
}
16161614
vimState.cursors = vimState.cursors.reverse();
16171615
vimState.isFakeMultiCursor = true;
1618-
vimState.isMultiCursor = true;
16191616
}
16201617
}
16211618

@@ -1654,7 +1651,6 @@ class CommandInsertNewLineBefore extends BaseCommand {
16541651
}
16551652
vimState.cursors = vimState.cursors.reverse();
16561653
vimState.isFakeMultiCursor = true;
1657-
vimState.isMultiCursor = true;
16581654
}
16591655
}
16601656

@@ -2489,7 +2485,6 @@ class ActionGoToInsertVisualBlockMode extends BaseCommand {
24892485

24902486
public async exec(position: Position, vimState: VimState): Promise<void> {
24912487
await vimState.setCurrentMode(Mode.Insert);
2492-
vimState.isMultiCursor = true;
24932488
vimState.isFakeMultiCursor = true;
24942489

24952490
for (const { line, start } of TextEditor.iterateLinesInBlock(vimState)) {
@@ -2520,7 +2515,6 @@ class ActionChangeInVisualBlockMode extends BaseCommand {
25202515
}
25212516

25222517
await vimState.setCurrentMode(Mode.Insert);
2523-
vimState.isMultiCursor = true;
25242518
vimState.isFakeMultiCursor = true;
25252519

25262520
for (const { start } of TextEditor.iterateLinesInBlock(vimState)) {
@@ -2553,7 +2547,6 @@ class ActionChangeToEOLInVisualBlockMode extends BaseCommand {
25532547
vimState.cursors = cursors;
25542548

25552549
await vimState.setCurrentMode(Mode.Insert);
2556-
vimState.isMultiCursor = true;
25572550
vimState.isFakeMultiCursor = true;
25582551
}
25592552
}
@@ -2571,7 +2564,6 @@ abstract class ActionGoToInsertVisualLineModeCommand extends BaseCommand {
25712564

25722565
public async exec(position: Position, vimState: VimState): Promise<void> {
25732566
await vimState.setCurrentMode(Mode.Insert);
2574-
vimState.isMultiCursor = true;
25752567
vimState.isFakeMultiCursor = true;
25762568

25772569
const resultingCursors: Cursor[] = [];
@@ -2693,7 +2685,6 @@ class ActionGoToInsertVisualBlockModeAppend extends BaseCommand {
26932685

26942686
vimState.cursors = newCursors;
26952687
await vimState.setCurrentMode(Mode.Insert);
2696-
vimState.isMultiCursor = true;
26972688
vimState.isFakeMultiCursor = true;
26982689
}
26992690
}

src/actions/commands/insert.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ export class CommandEscInsertMode extends BaseCommand {
106106

107107
if (vimState.isFakeMultiCursor) {
108108
vimState.cursors = [vimState.cursors[0]];
109-
vimState.isMultiCursor = false;
110109
vimState.isFakeMultiCursor = false;
111110
}
112111
}

src/mode/modeHandler.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
288288
return;
289289
}
290290

291-
if (e.selections.length === 1) {
292-
this.vimState.isMultiCursor = false;
293-
}
294-
295291
if (isStatusBarMode(this.vimState.currentMode)) {
296292
return;
297293
}

src/state/vimState.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ export class VimState implements vscode.Disposable {
7171
/**
7272
* Are multiple cursors currently present?
7373
*/
74-
// TODO: why isn't this a function?
75-
public isMultiCursor = false;
74+
public get isMultiCursor(): boolean {
75+
return this._cursors.length > 1;
76+
}
7677

7778
/**
7879
* Is the multicursor something like visual block "multicursor", where
@@ -181,7 +182,6 @@ export class VimState implements vscode.Disposable {
181182
}
182183

183184
this._cursors = [...map.values()];
184-
this.isMultiCursor = this._cursors.length > 1;
185185
}
186186

187187
/**

0 commit comments

Comments
 (0)