Skip to content

Commit

Permalink
fix (simpler) - cursor whenever changing editors - closes #2688
Browse files Browse the repository at this point in the history
  • Loading branch information
captaincaius committed Oct 5, 2018
1 parent 4a14b14 commit 24412f6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ICodeKeybinding {
commands?: { command: string; args: any[] }[];
}

export async function getAndUpdateModeHandler(): Promise<ModeHandler> {
export async function getAndUpdateModeHandler(forceSyncAndUpdate = false): Promise<ModeHandler> {
const activeEditorId = new EditorIdentity(vscode.window.activeTextEditor);

let [curHandler, isNew] = await ModeHandlerMap.getOrCreate(activeEditorId.toString());
Expand All @@ -44,7 +44,11 @@ export async function getAndUpdateModeHandler(): Promise<ModeHandler> {

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 });
}
Expand Down Expand Up @@ -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 });

Expand Down

0 comments on commit 24412f6

Please sign in to comment.