From 24412f6eef296e61176cb183aa826a9fc48b27f4 Mon Sep 17 00:00:00 2001 From: Captain Caius <241342+captaincaius@users.noreply.github.com> Date: Fri, 5 Oct 2018 17:05:38 +0300 Subject: [PATCH] fix (simpler) - cursor whenever changing editors - closes #2688 --- extension.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extension.ts b/extension.ts index 5081592cd0e..3486d01e4f7 100644 --- a/extension.ts +++ b/extension.ts @@ -34,7 +34,7 @@ interface ICodeKeybinding { commands?: { command: string; args: any[] }[]; } -export async function getAndUpdateModeHandler(): Promise { +export async function getAndUpdateModeHandler(forceSyncAndUpdate = false): Promise { const activeEditorId = new EditorIdentity(vscode.window.activeTextEditor); let [curHandler, isNew] = await ModeHandlerMap.getOrCreate(activeEditorId.toString()); @@ -44,7 +44,11 @@ export async function getAndUpdateModeHandler(): Promise { curHandler.vimState.editor = vscode.window.activeTextEditor!; - if (!previousActiveEditorId || !previousActiveEditorId.isEqual(activeEditorId)) { + if ( + forceSyncAndUpdate || + !previousActiveEditorId || + !previousActiveEditorId.isEqual(activeEditorId) + ) { curHandler.syncCursors(); await curHandler.updateView(curHandler.vimState, { drawSelection: false, revealRange: false }); } @@ -185,7 +189,7 @@ export async function activate(context: vscode.ExtensionContext) { taskQueue.enqueueTask(async () => { if (vscode.window.activeTextEditor !== undefined) { - const mh: ModeHandler = await getAndUpdateModeHandler(); + const mh: ModeHandler = await getAndUpdateModeHandler(true); await mh.updateView(mh.vimState, { drawSelection: false, revealRange: false });