mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-16 15:50:35 +03:00
Revert "Merge pull request #2880 from VSCodeVim/revert-2861-minor-performance-improvement"
This reverts commitd12e5d781b
, reversing changes made tob1bed18668
.
This commit is contained in:
parent
d41d02ce89
commit
4d3fa34329
14
extension.ts
14
extension.ts
@ -58,7 +58,11 @@ export async function getAndUpdateModeHandler(): Promise<ModeHandler> {
|
||||
}
|
||||
} else {
|
||||
previousActiveEditorId = activeEditorId;
|
||||
await curHandler.updateView(curHandler.vimState, { drawSelection: false, revealRange: false });
|
||||
await curHandler.updateView(curHandler.vimState, {
|
||||
drawSelection: false,
|
||||
revealRange: false,
|
||||
forceSetContext: false,
|
||||
});
|
||||
}
|
||||
|
||||
if (prevHandler && curHandler.vimState.focusChanged) {
|
||||
@ -238,7 +242,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 });
|
||||
mh.updateView(mh.vimState, { drawSelection: false, revealRange: false, forceSetContext: true });
|
||||
}
|
||||
|
||||
// This is called last because getAndUpdateModeHandler() will change cursor
|
||||
@ -337,7 +341,11 @@ async function handleActiveEditorChange(): Promise<void> {
|
||||
if (vscode.window.activeTextEditor !== undefined) {
|
||||
const mh = await getAndUpdateModeHandler();
|
||||
|
||||
mh.updateView(mh.vimState, { drawSelection: false, revealRange: false });
|
||||
mh.updateView(mh.vimState, {
|
||||
drawSelection: false,
|
||||
revealRange: false,
|
||||
forceSetContext: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
private _disposables: vscode.Disposable[] = [];
|
||||
private _modes: Mode[];
|
||||
private _remappers: Remappers;
|
||||
private _prevMode: ModeName;
|
||||
|
||||
public vimState: VimState;
|
||||
|
||||
@ -256,7 +257,11 @@ export class ModeHandler implements vscode.Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
await this.updateView(this.vimState, { drawSelection: toDraw, revealRange: true });
|
||||
await this.updateView(this.vimState, {
|
||||
drawSelection: toDraw,
|
||||
revealRange: true,
|
||||
forceSetContext: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1179,9 +1184,10 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
public async updateView(
|
||||
vimState: VimState,
|
||||
args: { drawSelection: boolean; revealRange: boolean } = {
|
||||
args: { drawSelection: boolean; revealRange: boolean; forceSetContext: boolean } = {
|
||||
drawSelection: true,
|
||||
revealRange: true,
|
||||
forceSetContext: false,
|
||||
}
|
||||
): Promise<void> {
|
||||
// Draw selection (or cursor)
|
||||
@ -1396,11 +1402,15 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
this._renderStatusBar();
|
||||
|
||||
await vscode.commands.executeCommand(
|
||||
'setContext',
|
||||
'vim.mode',
|
||||
ModeName[this.vimState.currentMode]
|
||||
);
|
||||
// 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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private _renderStatusBar(): void {
|
||||
|
Loading…
Reference in New Issue
Block a user