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

[Extension API] executeCommand 'editor.action.goToDeclaration' returns immediately #65809

Closed
jpoon opened this issue Dec 29, 2018 · 6 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-symbols definitions, declarations, references verified Verification succeeded

Comments

@jpoon
Copy link

jpoon commented Dec 29, 2018

Issue Type: Bug

I expected executeCommand to return once the goToDeclaration action has completed.

Sample Code:

    await vscode.commands.executeCommand('editor.action.goToDeclaration');
    console.log(vscode.window.activeTextEditor!.selection.start);
    await new Promise(resolve => setTimeout(resolve, 2000));
    console.log(vscode.window.activeTextEditor!.selection.start);

Console Output:

Object
line:502
character:15
Object
line:465
character:8

VS Code version: Code 1.30.1 (dea8705, 2018-12-18T18:12:07.165Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz (4 x 3400)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.93GB (8.72GB free)
Process Argv .
Screen Reader no
VM 0%
Extensions (5)
Extension Author (truncated) Version
python ms- 2018.12.1
csharp ms- 1.17.1
Go ms- 0.8.0
vscode-docker Pet 0.4.0
vim vsc 0.17.2
@jrieken jrieken added info-needed Issue requires more information from poster and removed info-needed Issue requires more information from poster labels Jan 3, 2019
@jrieken
Copy link
Member

jrieken commented Jan 3, 2019

I expected executeCommand to return once the goToDeclaration action has completed.

It does but only when calling it with correct arguments. In this case the position is missing and will have gotten an error for that.

@jrieken jrieken added the *dev-question VS Code Extension Development Question label Jan 3, 2019
@vscodebot
Copy link

vscodebot bot commented Jan 3, 2019

We have a great developer community over on slack where extension authors help each other. This is a great place for you to ask questions and find support.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Jan 3, 2019
@jpoon
Copy link
Author

jpoon commented Jan 3, 2019

Do you have an example of how it should be called (ie. what are the correct arguments)? Don't see any docs or examples of a position being passed to goToDeclaration.

@jrieken jrieken removed the *dev-question VS Code Extension Development Question label Jan 3, 2019
@jrieken jrieken reopened this Jan 3, 2019
@jrieken
Copy link
Member

jrieken commented Jan 3, 2019

Sorry, I had the wrong command in mind. Things should work the way you have written them. The editor must have a file open that supports go to declaration and it must not be an embedded editor, otherwise there are no restrictions.

@jpoon
Copy link
Author

jpoon commented Jan 3, 2019

The editor must have a file open that supports go to declaration and it must not be an embedded editor, otherwise there are no restrictions.

Yes, and yes. It probably helps if I shared the file of where I ran goToDeclaration, but looking at the output I shared above, you'll see that the cursor does move, it just takes a couple seconds to resolve, and there's on way to await it.

@jrieken jrieken added bug Issue identified by VS Code Team member as probable bug editor-symbols definitions, declarations, references labels Jan 3, 2019
@jrieken jrieken added this to the December/January 2019 milestone Jan 3, 2019
@jrieken
Copy link
Member

jrieken commented Jan 3, 2019

There is actually one level of promises that we don't await. I will push a fix

@jrieken jrieken closed this as completed Jan 3, 2019
@sbatten sbatten added the verified Verification succeeded label Jan 31, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-symbols definitions, declarations, references verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants