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

CMD+ALT+Click on a symbol opens the source file with the symbol twice in two separate editors #232725

Closed
CodingMarkus opened this issue Oct 31, 2024 · 5 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@CodingMarkus
Copy link

CodingMarkus commented Oct 31, 2024

  • VS Code Version: 1.94.2
  • OS Version: macOS 14.6.1

Steps to Reproduce:

  1. Have two code editors open side by side
  2. One shows file A (left), the other shows file B (right)
  3. Click a symbol in editor A while pressing CMD+ALT

Expected behavior:
The editor to the right now shows file C where the clicked symbol is located. Alternatively a 3rd editor opens that shows file C and the editor in the middle still shows file B. Both could be expected, yet I would expect the first one to happen.

Actual behavior:
The editor to the right now shows file C where the clicked symbol is located but another editor is also opened and this editor also shows file C.

Screenshots:

Initial situation:

Image

I hold CMD+ALT and click on em_asm.h and this is what I get:

Image

Note how the editor to the right changes to a different file but also note there is also a third editor that also shows that file.

Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.95.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@CodingMarkus
Copy link
Author

Still happens in 1.95.0

Also checked with the clangd extension developers, as their extension makes C header files clickable in the first place and it turned out to only happen when clicking header files. It works correctly when clicking other symbols. Say believe that this is a VSCode issue.

See clangd/vscode-clangd#711

@CodingMarkus
Copy link
Author

Okay, the source of the problem is known:

There are two different editor features at play here:

  • Go to definition. This applies to arbitrary tokens in the code. The editor sends a textDocument/definition request on demand for a given source location (i.e. when go-to-definition is invoked by the user at that location), and the language server responds with the location of the definition of the symbol at the input location (and the editor then navigates there, including opening the target file if it's different from the original file).
  • Document links. This is meant for source ranges in a document which are references/links to another document. This is requested once for the entire document with textDocument/documentLink and the response contains all links in the document. The editor then renders these ranges as links (e.g. with an underline) and can provide a way to follow the link.

For #include directives, clangd supports both of these features: it includes them in textDocument/documentLinks, and it responds to textDocument/definition on them with the first character position of the included file.

Now, it looks like VSCode binds the same shortcut, Ctrl+Alt+Click (or Cmd+Alt+Click on Mac), to both of these editor features. This is why two copies of the target file are opened.

@vs-code-engineering vs-code-engineering bot added the stale Issues that have not been triaged in an appropriate amount of time label Nov 12, 2024
@chrmarti chrmarti assigned jrieken and unassigned chrmarti and ulugbekna Nov 13, 2024
@chrmarti chrmarti removed triage-needed stale Issues that have not been triaged in an appropriate amount of time labels Nov 13, 2024
@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label Nov 13, 2024
Copy link

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
@CodingMarkus
Copy link
Author

Where is that duplicate? Why don't you link it, if it exists?

I cannot find any duplicate and it's a bold claim that this is a duplicate, yet not providing any evidence for it or any way for people to check if that is really the case. This is very unprofessional. Professional bug tracking means you only close something as duplicate after providing a link to the duplicate and allow the reporter of the issue to verify that it really is a duplicate and not just a similar, yet unrelated issue.

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

4 participants