-
Notifications
You must be signed in to change notification settings - Fork 54
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
Use F3 to switch between "Open Definition" and "Open Declaration", e.g. for switching between header and cpp files in C++ #1104
Comments
While I think this might be a good idea here and there, I'm afraid it will not be an expected behavior for the target audience: Jumping to implementation when triggering the "Go to definition" operation would seem rather unexpected. At least in Eclipse IDE with JDT, it would really feel strange and could be perceived as a bug. |
Hi @mickaelistria,
I think, you probably got me wrong. Today, LSP4E creates a list of all potential link targets for the element under cursor. That list is built as follows (see
These lists are combined in one list containing all the elements. When hitting F3, LSP4E selects the first element from that list. Sometimes it selects the element the the cursor is already on. My proposal is to change the order as follows:
As you see, the implementations and type definitions are already contained in the list of all results. I didn't plan to change that. I only propose to move the definitions and declarations that are known to be under the cursor to the end of all definitions and declarations. This way, if a user has a cursor on a method definition in a cpp file, he/she would jump to the corresponding declaration in a hpp file and vice versa, without loosing the remaining link targets or their order when using the same code for Ctrl + click navigation. |
IIRC, it's supposed to always put |
Dear @mickaelistria, If (for some reason) it's desired to always put all definitions first, do you have an idea how LSP4E could allow e.g. CDT LSP to change that particular behavior in such a way that (similar to CDT) F3 jumps from declaration to definition and vice versa? Besides, my assumption was that removing the definition / declaration that the cursor is already on is not desired. Is that correct? Otherwise, it might be an option to just remove these from the result list, without changing any order. I also checked the hyperLinkDetector extension point ( Another idea:
with this? (see this code in
In |
I'd like to slightly change how LSP4E collects and uses definitions, declarations, implementations and type definitions for a cursor position or for a selection in an LSP-based text editor. My goal is the following: For C++ editors (in CDT LSP), by pressing F3 a user should jump to the definition or to the declaration of the element under cursor and by pressing F3 multiple times just jump from a method's declaration (usually in a header file) to its definition (usually in a cpp file) and vice versa. In general, F3 should not just pick the first element from the list of all definitions, declarations, type definitions, and implementations, but at least select one of these that the cursor is not already placed upon.
At the moment, pressing F3 always opens the first definition (or declaration or type definition or implementation) found, even if the cursor is already placed on that definition.
My proposal is to detect the element that the cursor is placed upon and place that element (a definition or declaration) to the end of the list of all definitions and declarations, then followed by the type definitions and implementations.
I.e., the only thing that would change is the order of the definitions, declarations, type definitions and implementations in the list that is used to pick the element to jump to (the first element from that list is used as target). The same list is used when using Ctrl + click to select an element to jump to. Since we wouldn't remove any element from that list, that change should work for both use cases.
This issue might be related to issue #332.
The text was updated successfully, but these errors were encountered: