Skip to content

Commit

Permalink
Refactor: stop passing VimState around in ModeHandler
Browse files Browse the repository at this point in the history
This is entirely unnecessary, as each ModeHandler only ever deals with a single VimState, and that's `this.vimState`, which is never re-assigned.
Baby step toward VSCodeVim#4698
  • Loading branch information
J-Fields committed Aug 17, 2020
1 parent c7e5ca2 commit b1f5d95
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 257 deletions.
8 changes: 4 additions & 4 deletions extensionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function getAndUpdateModeHandler(forceSyncAndUpdate = false): Promi
// 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(curHandler.vimState, { drawSelection: false, revealRange: false });
await curHandler.updateView({ drawSelection: false, revealRange: false });
}

previousActiveEditorId = activeEditorId;
Expand Down Expand Up @@ -398,7 +398,7 @@ export async function activate(
registerCommand(context, 'vim.showQuickpickCmdLine', async () => {
const mh = await getAndUpdateModeHandler();
await commandLine.PromptAndRun('', mh.vimState);
mh.updateView(mh.vimState);
mh.updateView();
});

registerCommand(context, 'vim.remap', async (args: ICodeKeybinding) => {
Expand All @@ -416,7 +416,7 @@ export async function activate(
// Check if this is a vim command by looking for :
if (command.command.startsWith(':')) {
await commandLine.Run(command.command.slice(1, command.command.length), mh.vimState);
mh.updateView(mh.vimState);
mh.updateView();
} else {
vscode.commands.executeCommand(command.command, command.args);
}
Expand Down Expand Up @@ -449,7 +449,7 @@ export async function activate(
if (vscode.window.activeTextEditor) {
let mh = await getAndUpdateModeHandler();
// This is called last because getAndUpdateModeHandler() will change cursor
mh.updateView(mh.vimState, { drawSelection: false, revealRange: false });
mh.updateView({ drawSelection: false, revealRange: false });
}

// Disable automatic keyboard navigation in lists, so it doesn't interfere
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 {
commandString.slice(1, commandString.length),
modeHandler.vimState
);
await modeHandler.updateView(modeHandler.vimState);
await modeHandler.updateView();
} else if (commandArgs) {
await vscode.commands.executeCommand(commandString, commandArgs);
} else {
Expand Down
Loading

0 comments on commit b1f5d95

Please sign in to comment.