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

Fixes #1532: gd doesn't set desiredColumn properly #1605

Merged
merged 5 commits into from
Apr 30, 2017
Merged
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
19 changes: 11 additions & 8 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ export class ModeHandler implements vscode.Disposable {
];
this.vimState.historyTracker = new HistoryTracker(this.vimState);
this.vimState.easyMotion = new EasyMotion();

if (Configuration.startInInsertMode) {
this._vimState.currentMode = ModeName.Insert;
} else {
Expand All @@ -534,13 +533,17 @@ export class ModeHandler implements vscode.Disposable {
// position to the position that VSC set it to.

// This also makes things like gd work.
if (this._vimState.editor) {
this._vimState.cursorStartPosition = Position.FromVSCodePosition(this._vimState.editor.selection.start);
this._vimState.cursorPosition = Position.FromVSCodePosition(this._vimState.editor.selection.start);
this._vimState.desiredColumn = this._vimState.cursorPosition.character;

this._vimState.whatILastSetTheSelectionTo = this._vimState.editor.selection;
}
// For whatever reason, the editor positions aren't updated until after the
// stack clears, which is why this setTimeout is necessary
setTimeout(() => {
if (this._vimState.editor) {
this._vimState.cursorStartPosition = Position.FromVSCodePosition(this._vimState.editor.selection.start);
this._vimState.cursorPosition = Position.FromVSCodePosition(this._vimState.editor.selection.start);
this._vimState.desiredColumn = this._vimState.cursorPosition.character;

this._vimState.whatILastSetTheSelectionTo = this._vimState.editor.selection;
}
}, 0);

// Handle scenarios where mouse used to change current position.
const disposer = vscode.window.onDidChangeTextEditorSelection((e: vscode.TextEditorSelectionChangeEvent) => {
Expand Down