question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LSP integration: inconsistent handling of goto-definition for selected text

See original GitHub issue
  • VSCode Version: 1.43.0
  • OS Version: macOS Catalina 1.15.3

Triggering goto-definition on selected (e.g. to copy) text depends upon how the text itself was selected.

This is because the goto definition request uses a different text position depending upon the end point of the selection. For a fix, I think it should always use the beginning of the selection as judged by earlier file offset.

Steps to Reproduce:

  1. Use any LSP that’s available within VSCode. For my example, I’ll be using https://github.com/apple/sourcekit-lsp on itself
  2. I’ll be using the text here:

extension BuildServerBuildSystem: BuildSystem {

Examples:

  1. extension BuildServerBuildSystem: BuildSystem { --------------------- ^ ----------- double click to select Goto-definition doesn’t work (VSCode appears to send the position at char :)

  2. extension BuildServerBuildSystem: BuildSystem { ------------ ^------------------------^ ------------start------------------- end Goto-definition doesn’t work (VSCode appears to send the position at char :)

  3. extension BuildServerBuildSystem: BuildSystem { ------------ ^------------------------^ ------------end------------------- start Goto-definition does work (VSCode appears to send the position at char )

For these cases VSCode should also send the position at char before the selection

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
dbaeumercommented, Mar 23, 2020

I actually disagree. The position that should be used is the one where the cursor blinks. Otherwise it is IMO confusion for the user.

0reactions
dbaeumercommented, Oct 8, 2020

Added this to the spec:

It is up to the client to decide how a selection is converted into a position when issuing a request for a text document. The client can for example honor or ignore the selection direction to make LSP request consistent with features implemented internally.

I think we need a different item if we want to support selections instead of positions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

inconsistent handling of goto-definition for selected text · Issue ...
For a fix, I think it should always use the beginning of the selection as judged by earlier file offset. Steps to Reproduce:...
Read more >
Language Server Protocol Specification - 3.17
It is up to the client to decide how a selection is converted into a position when issuing a request for a text...
Read more >
How to Transform Text Editors into Code Editors with LSP
Save time transforming text editors into code editors using LSP. Add your own ideas to the open-world with helpful tips detailed in this...
Read more >
Why LSP? - Hacker News
The I means Integrated, and VS Code with plugins and LSPs is anything but. ... e.g., if you move a selected line of...
Read more >
Integrating Xtext Language Server Support in Visual Studio ...
Now select the identifier Other and select 'Go to definition' from the context menu. This will open B.mydsl and select the definition of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found