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

Support gd #547

Merged
merged 2 commits into from
Aug 2, 2016
Merged
Changes from 1 commit
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: 18 additions & 0 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1343,10 +1343,28 @@ class CommandGoToDefinition extends BaseCommand {
keys = ["g", "d"];

public async exec(position: Position, vimState: VimState): Promise<VimState> {
const startPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);

await vscode.commands.executeCommand("editor.action.goToDeclaration");

// Unfortuantely, the above does not necessarily have to have finished executing
// (even though we do await!). THe only way to ensure it's done is to poll, which is
// a major bummer.

await new Promise(resolve => {
let interval = setInterval(() => {
const positionNow = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);

if (!startPosition.isEqual(positionNow)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be a problem if the gd happens to be a no-op movement?

Copy link
Member Author

@johnfn johnfn Aug 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that was rather mindless of me. Good catch. Opened #553 as a self-reminder.

clearInterval(interval);
resolve();
}
}, 50);
});

vimState.focusChanged = true;
vimState.cursorPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);

return vimState;
}
}
Expand Down