Skip to content

Commit

Permalink
ModeHandler.updateView() doesn't need to be async
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Fields committed Sep 10, 2024
1 parent 9a2eb92 commit ee10a02
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion extensionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function getAndUpdateModeHandler(
// need to update our representation of the cursors when switching between editors for the same document.
// This will be unnecessary once #4889 is fixed.
curHandler.syncCursors();
await curHandler.updateView({ drawSelection: false, revealRange: false });
curHandler.updateView({ drawSelection: false, revealRange: false });
}

previousActiveEditorUri = activeTextEditor.document.uri;
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/remapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export class Remapper implements IRemapper {
} else {
throw VimError.fromCode(ErrorCode.NotAnEditorCommand, commandString);
}
await modeHandler.updateView();
modeHandler.updateView();
} else {
await vscode.commands.executeCommand(commandString, ...commandArgs);
}
Expand Down
18 changes: 9 additions & 9 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
Logger.trace('Updating Visual Selection!');
this.vimState.cursorStopPosition = selection.active;
this.vimState.cursorStartPosition = selection.anchor;
await this.updateView({ drawSelection: false, revealRange: false });
this.updateView({ drawSelection: false, revealRange: false });

// Store selection for commands like gv
this.vimState.lastVisualSelection = {
Expand All @@ -285,7 +285,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
this.vimState.cursorStopPosition = selection.active;
this.vimState.cursorStartPosition = selection.anchor;
await this.setCurrentMode(Mode.Visual);
await this.updateView({ drawSelection: false, revealRange: false });
this.updateView({ drawSelection: false, revealRange: false });

// Store selection for commands like gv
this.vimState.lastVisualSelection = {
Expand Down Expand Up @@ -349,7 +349,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
this.vimState.cursorStopPosition = selection.active;
this.vimState.cursorStartPosition = selection.anchor;
this.vimState.desiredColumn = selection.active.character;
await this.updateView({ drawSelection: false, revealRange: false });
this.updateView({ drawSelection: false, revealRange: false });
}
return;
}
Expand Down Expand Up @@ -632,7 +632,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
// TODO: this call to updateView is only used to update the virtualCharacter and halfBlock
// cursor decorations, if in the future we split up the updateView function there should
// be no need to call all of it.
await this.updateView({ drawSelection: false, revealRange: false });
this.updateView({ drawSelection: false, revealRange: false });
}
}
}
Expand Down Expand Up @@ -746,7 +746,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
}

// Update view
await this.updateView();
this.updateView();

if (action.isJump) {
globalState.jumpTracker.recordJump(
Expand Down Expand Up @@ -1232,7 +1232,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
return;
}

await this.updateView();
this.updateView();
if (
replayMode === ReplayMode.Replace &&
!(j === transformation.count - 1 && i === actions.length - 1)
Expand Down Expand Up @@ -1275,7 +1275,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
break;
}

await this.updateView();
this.updateView();

if (action.isJump) {
globalState.jumpTracker.recordJump(originalLocation, Jump.fromStateNow(this.vimState));
Expand Down Expand Up @@ -1333,12 +1333,12 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
);
}

public async updateView(
public updateView(
args: { drawSelection: boolean; revealRange: boolean } = {
drawSelection: true,
revealRange: true,
},
): Promise<void> {
): void {
// Draw selection (or cursor)
if (args.drawSelection) {
let selectionMode: Mode = this.vimState.currentMode;
Expand Down
2 changes: 1 addition & 1 deletion src/transformations/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Transformer } from './transformer';
export interface IModeHandler {
vimState: VimState;

updateView(args?: { drawSelection: boolean; revealRange: boolean }): Promise<void>;
updateView(args?: { drawSelection: boolean; revealRange: boolean }): void;
runMacro(recordedMacro: RecordedState): Promise<void>;
handleMultipleKeyEvents(keys: string[]): Promise<void>;
handleKeyEvent(key: string): Promise<void>;
Expand Down

0 comments on commit ee10a02

Please sign in to comment.