Skip to content

Commit

Permalink
Merge pull request #3103 from captaincaius/active-text-editor-eventha…
Browse files Browse the repository at this point in the history
…ndler-fix

fix (simpler) - cursor whenever changing editors - closes #2688
  • Loading branch information
xconverge committed Oct 9, 2018
2 parents 0b16120 + 24412f6 commit 01d2dce
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.updateVimModeForKeybindings(mh.vimState.currentMode);

Expand Down

0 comments on commit 01d2dce

Please sign in to comment.