Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert back to previous non-async code when syncing cursor #3435

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

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

/**
Expand Down
6 changes: 3 additions & 3 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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