Vscode: With multiple definitions "Go to definition" shows peek definition popup instead of going to definition

Created on 8 Mar 2019  路  11Comments  路  Source: microsoft/vscode


  • VSCode Version: 1.32.1 (1.32.1)
  • OS Version: 10.14.3 (18D109)

Steps to Reproduce:

  • happens sometimes when I work with JS files. I couldn't find a pattern in when it works and when it does not... It's extremely frustrating


Does this issue occur when all extensions are disabled?: Yes

editor-symbols feature-request on-testplan under-discussion

Most helpful comment

With next Insiders build (http://code.visualstudio.com/insiders/, tomorrow or sooner) there will be a new setting: editor.gotoLocation.many which controls what happens when encountering multiple definition/declarations of a symbols. Possible values are

  • 'peek' (default) - Open peek with all results at the position of the request
  • 'revealAndPeek' - Reveal the first result and open peek with all results there
  • 'reveal' - Reveal the first result and ignore others

All 11 comments

Also happening on insiders.

It happens for TS files as well. A click to Go to Definition from context menu also shows definitions popup.

That's the outcome of https://github.com/Microsoft/vscode/pull/68023. When having multiple definition of a symbol the following change was made:

  • before: open the nearest symbol and show peek at its position
  • after: show peek at position of request

So, this happens whenever multiple definitions of a symbol exist. Instead of making a decision where to go to first, VS Code now shows peeks without revealing one. After reading/hearing feedback I was under the assumption that is wanted but we can consider an options if people feel strong about restoring the previous, jump to nearest, definition behaviour.

"Go to" should work as "go to" I guess. Jumping to a nearest definition was the well-worked thing for me. Right now I always need to one additional mouse move + click every time I'm navigating to definitions. That's happening very often because jumping, for example, to any styled component in react application with types from DT always have two references, one reference is mine and one reference from DT:

Screenshot 2019-03-10 at 11 45 10

Obviously the second one isn't interesting for me. So please add the option to restore the previous behaviour. Or something like Go to closest definition.

Shouldn't it go to the definition of the variable?
if I have declared a function/variable and exported, it seems going to the declaration make more sense no?

Also what's the difference between "Goto Definition" and "Pick Definition" now, it seems they both do the same thing.

IMO, these changes are making VSCode less convenient.

Also what's the difference between "Goto Definition" and "Pick Definition" now, it seems they both do the same thing.

"Peek Definition" always shows the peek window, "Go To Definition" shows it when having multiple definitions. We didn't change that, what we have changed is that peek opens at the position of the request, not at the position of the first definition.

I will add a setting that allows to restore the old behaviour, to workaround until then, hit Enter and the the first definition will be revealed.

@jrieken I don't get the

"Go To Definition" shows it when having multiple definitions

part...

I don't see how a symbol (an import in JS in my case) can have multiple definitons.

for example:

export { Cart: createIcon(Cart) }

where createIcon is a HOC, that takes imported svg React component from elsewhere, and wraps it in some wrappers.

It seems to me that Cart's go to definition would take me to where Cart is defined, but instead this shows up:

image

I don't see how a symbol (an import in JS in my case) can have multiple definitons.

Let's keep that out of this issue. Generally, a symbol can have multiple definitions and this issue is about the UI for that case, e.g where to show peek for multiple symbols. If you disagree with how TypeScript computes definitions for a certain symbol and if you think it should be 1, not more, then we should move that into a separate issue.

With next Insiders build (http://code.visualstudio.com/insiders/, tomorrow or sooner) there will be a new setting: editor.gotoLocation.many which controls what happens when encountering multiple definition/declarations of a symbols. Possible values are

  • 'peek' (default) - Open peek with all results at the position of the request
  • 'revealAndPeek' - Reveal the first result and open peek with all results there
  • 'reveal' - Reveal the first result and ignore others
Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipgiuliani picture philipgiuliani  路  3Comments

mrkiley picture mrkiley  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

trstringer picture trstringer  路  3Comments

vsccarl picture vsccarl  路  3Comments