Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression with setContext in modeHandler #2880

Merged
merged 1 commit into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ export async function getAndUpdateModeHandler(): Promise<ModeHandler> {
}
} else {
previousActiveEditorId = activeEditorId;
await curHandler.updateView(curHandler.vimState, {
drawSelection: false,
revealRange: false,
forceSetContext: false,
});
await curHandler.updateView(curHandler.vimState, { drawSelection: false, revealRange: false });
}

if (prevHandler && curHandler.vimState.focusChanged) {
Expand Down Expand Up @@ -242,7 +238,7 @@ export async function activate(context: vscode.ExtensionContext) {
// Initialize mode handler for current active Text Editor at startup.
if (vscode.window.activeTextEditor) {
let mh = await getAndUpdateModeHandler();
mh.updateView(mh.vimState, { drawSelection: false, revealRange: false, forceSetContext: true });
mh.updateView(mh.vimState, { drawSelection: false, revealRange: false });
}

// This is called last because getAndUpdateModeHandler() will change cursor
Expand Down Expand Up @@ -341,11 +337,7 @@ async function handleActiveEditorChange(): Promise<void> {
if (vscode.window.activeTextEditor !== undefined) {
const mh = await getAndUpdateModeHandler();

mh.updateView(mh.vimState, {
drawSelection: false,
revealRange: false,
forceSetContext: true,
});
mh.updateView(mh.vimState, { drawSelection: false, revealRange: false });
}
});
}
Expand Down
24 changes: 7 additions & 17 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class ModeHandler implements vscode.Disposable {
private _disposables: vscode.Disposable[] = [];
private _modes: Mode[];
private _remappers: Remappers;
private _prevMode: ModeName;

public vimState: VimState;

Expand Down Expand Up @@ -257,11 +256,7 @@ export class ModeHandler implements vscode.Disposable {
}
}

await this.updateView(this.vimState, {
drawSelection: toDraw,
revealRange: true,
forceSetContext: false,
});
await this.updateView(this.vimState, { drawSelection: toDraw, revealRange: true });
}
}

Expand Down Expand Up @@ -1184,10 +1179,9 @@ export class ModeHandler implements vscode.Disposable {

public async updateView(
vimState: VimState,
args: { drawSelection: boolean; revealRange: boolean; forceSetContext: boolean } = {
args: { drawSelection: boolean; revealRange: boolean } = {
drawSelection: true,
revealRange: true,
forceSetContext: false,
}
): Promise<void> {
// Draw selection (or cursor)
Expand Down Expand Up @@ -1402,15 +1396,11 @@ export class ModeHandler implements vscode.Disposable {

this._renderStatusBar();

// Only update the context if the mode has changed for performance reasons
if (args.forceSetContext || this._prevMode !== this.vimState.currentMode) {
this._prevMode = this.vimState.currentMode;
await vscode.commands.executeCommand(
'setContext',
'vim.mode',
ModeName[this.vimState.currentMode]
);
}
await vscode.commands.executeCommand(
'setContext',
'vim.mode',
ModeName[this.vimState.currentMode]
);
}

private _renderStatusBar(): void {
Expand Down