From f58400c244350dcf3046bd824741edd82530ba43 Mon Sep 17 00:00:00 2001 From: Jason Poon Date: Thu, 31 Jan 2019 11:07:47 -0800 Subject: [PATCH] fix: revert back to previous non-async code when syncing cursor. closes #3431 --- extension.ts | 18 +++++++++++------- src/mode/modeHandler.ts | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/extension.ts b/extension.ts index fa4bcfb348e..629173caf69 100644 --- a/extension.ts +++ b/extension.ts @@ -49,7 +49,7 @@ export async function getAndUpdateModeHandler(forceSyncAndUpdate = false): Promi !previousActiveEditorId || !previousActiveEditorId.isEqual(activeEditorId) ) { - await curHandler.syncCursors(); + curHandler.syncCursors(); await curHandler.updateView(curHandler.vimState, { drawSelection: false, revealRange: false }); } @@ -92,9 +92,15 @@ export async function activate(context: vscode.ExtensionContext) { // we need to load the configuration first await loadConfiguration(); + const logger = Logger.get('Extension Startup'); + logger.debug('Start'); + extensionContext = context; extensionContext.subscriptions.push(StatusBar); + // load state + await Promise.all([commandLine.load(), globalState.load()]); + // workspace events registerEventListener( context, @@ -356,15 +362,13 @@ 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(); + // This is called last because getAndUpdateModeHandler() will change cursor mh.updateView(mh.vimState, { drawSelection: false, revealRange: false }); } - await Promise.all([ - commandLine.load(), - globalState.load(), - // This is called last because getAndUpdateModeHandler() will change cursor - toggleExtension(configuration.disableExtension, compositionState), - ]); + await toggleExtension(configuration.disableExtension, compositionState); + + logger.debug('Finish.'); } /** diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 7893b0c6e4b..18d33dcff0f 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -49,7 +49,7 @@ export class ModeHandler implements vscode.Disposable { await modeHandler.setCurrentMode( configuration.startInInsertMode ? ModeName.Insert : ModeName.Normal ); - await modeHandler.syncCursors(); + modeHandler.syncCursors(); return modeHandler; } @@ -77,8 +77,8 @@ export class ModeHandler implements vscode.Disposable { /** * Syncs cursors between vscode representation and vim representation */ - public async syncCursors() { - return require('util').promisify(setTimeout)(() => { + public syncCursors() { + setImmediate(() => { if (this.vimState.editor) { this.vimState.cursorStartPosition = Position.FromVSCodePosition( this.vimState.editor.selection.start