Skip to content

DefinitionLink targetSelectionRange not working as expected #58649

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

Closed
KamasamaK opened this issue Sep 13, 2018 · 8 comments
Closed

DefinitionLink targetSelectionRange not working as expected #58649

KamasamaK opened this issue Sep 13, 2018 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-symbols definitions, declarations, references verified Verification succeeded

Comments

@KamasamaK
Copy link

Issue Type: Bug

Scenario 1:

  1. Use Peek Definition on a symbol that has a DefinitionLink provided with targetSelectionRange defined.
  2. The range provided by DefinitionLink.targetRange is used for highlighting.

Scenario 2:

  1. Use Go to Definition on a symbol that has a DefinitionLink provided with targetSelectionRange defined.
  2. Navigates to beginning of DefinitionLink.targetRange

I am assuming that in at least one of the above scenarios, DefinitionLink.targetSelectionRange should be used instead of DefinitionLink.targetRange. It is not clear based on the documentation, so I am not sure in what case DefinitionLink.targetSelectionRange is supposed to be used, but I figure it must be used for something. I am expecting it to work similarly to DocumentSymbol.selectionRange.

VS Code version: Code 1.27.2 (f46c4c4, 2018-09-12T16:17:45.060Z)
OS version: Windows_NT x64 10.0.17134

@vscodebot
Copy link

vscodebot bot commented Sep 13, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@jrieken jrieken assigned mjbvz and unassigned jrieken Sep 17, 2018
@jrieken jrieken added the bug Issue identified by VS Code Team member as probable bug label Sep 17, 2018
@jrieken
Copy link
Member

jrieken commented Sep 17, 2018

I believe this happened with 0a1b3a5

@vscodebot vscodebot bot removed the new release label Sep 17, 2018
@mjbvz mjbvz added this to the September 2018 milestone Sep 17, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Sep 17, 2018

Not a regression; we just never hooked anything up to use targetSelectionRange after adding this api

I believe targetSelectionRange should be the span we reveal when you run go to definition or click in the peek definition view. The targetRange should be the highlighted span

@mjbvz mjbvz added the api label Sep 17, 2018
@KamasamaK
Copy link
Author

KamasamaK commented Sep 18, 2018

Even though that makes sense, I'm not sure I like the idea of using the targetRange for highlighting in the Peek Definition view. It's mostly because of the styling, which at least in the default Dark+ theme is very overwhelming and harms the visibility of the syntax highlighting.

I would ask that after making this change, you implement DefinitionLink usage with proper ranges for TypeScript and see if you still like it. The range that the TypeScript extension currently uses for definitions is understandably what I would describe as just the targetSelectionRange.

@dbaeumer
Copy link
Member

@mjbvz any plans when this will be addressed. I want to hook this up in LSP and document this correctly. So I will for now convert targetSelectionRange to targetRange on the API side to have a decent behaviour.

The other question is why targetSelectionRange is optional. Shouldn't it be mandatory in this example as it is with DocumentSymbol

@jrieken jrieken assigned jrieken and unassigned mjbvz Jan 10, 2019
@jrieken jrieken added editor-symbols definitions, declarations, references and removed api labels Jan 10, 2019
jrieken added a commit that referenced this issue Jan 11, 2019
jrieken added a commit that referenced this issue Jan 11, 2019
@jrieken jrieken closed this as completed Jan 11, 2019
@aeschli
Copy link
Contributor

aeschli commented Feb 1, 2019

@jrieken Trying to validate that, I now see that the targetSelectionRange is what is highlighted in the peek view and is used as the range to navigate to.
Not clear to me what the targetRange does or can bee seen.

Is that the expected behaviour? Can the spec be clarified?

@aeschli aeschli added the verification-steps-needed Steps to verify are needed for verification label Feb 1, 2019
@jrieken
Copy link
Member

jrieken commented Feb 4, 2019

Not clear to me what the targetRange does or can bee seen.

Yeah, that's actually not yet used. The point is to use target selection range when given. The idea of the target range is that we can use it for the preview hover when cmd+hovering over a declaration link.

@jrieken
Copy link
Member

jrieken commented Feb 4, 2019

Adding verified as @aeschli did all that there can be done

@jrieken jrieken added verified Verification succeeded and removed verification-steps-needed Steps to verify are needed for verification labels Feb 4, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 25, 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

5 participants