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

✨ Jump to Definition #1902

Open
austincondiff opened this issue Oct 12, 2024 · 0 comments
Open

✨ Jump to Definition #1902

austincondiff opened this issue Oct 12, 2024 · 0 comments
Labels
enhancement New feature or request language server Issues or Pull Requests related to language servers. source editor

Comments

@austincondiff
Copy link
Collaborator

austincondiff commented Oct 12, 2024

Description

We would like to add a “Jump to Definition” feature that will allow users to quickly navigate to the definition or declaration of variables, functions, classes, and other symbols in their code. It will improve code navigation by letting users jump between symbol definitions efficiently.

Expected Behavior

  1. Jump to Definition should be triggered in the following ways:
    • clicking a symbol should execute the Jump to Definition action.
    • J should jump to the symbol’s definition.
    • The option should also be available from the Navigate menu under the name “Jump to Definition.”
  2. When the key is held and the mouse hovers over a symbol, the symbol should display a background with the accent color to indicate it is clickable.
  3. Clicking the symbol or pressing the shortcut should:
    • Check if the symbol has a valid definition within the same file or another file in the project.
    • Navigate the user to the location of the symbol’s definition.
  4. If the symbol is defined in an external library or dependency, CodeEdit should provide a way to open the relevant file or show the external definition if possible.

Implementation Details

  1. Language Server Protocol (LSP) Integration:
    • This feature can leverage LSP’s textDocument/definition capability for supported languages. The LSP server will return the location of the symbol’s definition, which CodeEdit will then navigate to.
  2. UI/UX Considerations:
    • When is held down and the mouse hovers over a symbol, the symbol should be highlighted with a background in the system’s accent color to indicate it’s clickable.
    • If the symbol definition is within the same file, CodeEdit should smoothly scroll to the appropriate line.
    • If the definition is in another file, CodeEdit should open that file and navigate to the correct line, focusing on the symbol’s definition.
  3. Menu Integration:
    • Add a “Jump to Definition” option to the Navigate menu.
    • Assign J as the default keyboard shortcut for this action.
  4. Error Handling:
    • If the symbol definition cannot be found, an appropriate message (e.g., “Definition not found”) should be shown to the user.
    • Handle cases where symbols may reference external dependencies gracefully, providing feedback if the symbol’s definition is unavailable.

Keyboard Shortcut & Menu Option:

  • J should trigger the Jump to Definition command.
  • The Navigate menu should include “Jump to Definition” as an option.
  • click on symbols should trigger the same action for mouse-based navigation.

Acceptance Criteria

  1. clicking a symbol triggers the Jump to Definition action, and the symbol is highlighted with an accent color background while the command key is held.
  2. J successfully jumps to the definition of a selected symbol.
  3. The Jump to Definition option is available in the Navigate menu.
  4. If the definition is in the same file, smooth scrolling moves to the symbol’s definition.
  5. If the definition is in a different file, CodeEdit opens the file and navigates to the correct line.
  6. If the symbol definition cannot be found, an error message is displayed to the user.
  7. The feature works for languages supported by CodeEdit’s LSP integration.
  8. The accent color background appears when is held, and the symbol is clickable.

Additional Context

  • Future iterations could include a “Peek Definition” feature, allowing users to view definitions in a pop-up without leaving the current file.
  • Support for external libraries or dependencies could be extended to provide more detailed navigation options.

Related Features:

  • Integrate with a future Find All References feature for improved code exploration.
  • Consider adding a “Peek Definition” feature.

Screenshots

Screen.Recording.2024-10-12.at.11.31.06.AM.mov
@austincondiff austincondiff added the enhancement New feature or request label Oct 12, 2024
@github-actions github-actions bot added bug Something isn't working feedback find language server Issues or Pull Requests related to language servers. other triage needed UI This is UI related UX User Experience labels Oct 12, 2024
@austincondiff austincondiff added source editor and removed bug Something isn't working UI This is UI related feedback other UX User Experience triage needed find labels Oct 12, 2024
@austincondiff austincondiff moved this from 🆕 New to 📋 Todo in CodeEdit Project Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language server Issues or Pull Requests related to language servers. source editor
Projects
Status: 📋 Todo
Development

No branches or pull requests

1 participant