✨ Jump to Definition
@thecoolwinter 已经在做这个了。
开始于 2025年7月26日。
评估
这个 Issue 还没有评估数据。
描述
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
- 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.”
- 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.
- 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.
- 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
- 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.
- 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.
- Menu Integration:
- Add a “Jump to Definition” option to the Navigate menu.
- Assign ⌃ ⌘ J as the default keyboard shortcut for this action.
- 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
- ⌘ 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.
- ⌃ ⌘ J successfully jumps to the definition of a selected symbol.
- The Jump to Definition option is available in the Navigate menu.
- If the definition is in the same file, smooth scrolling moves to the symbol’s definition.
- If the definition is in a different file, CodeEdit opens the file and navigates to the correct line.
- If the symbol definition cannot be found, an error message is displayed to the user.
- The feature works for languages supported by CodeEdit’s LSP integration.
- 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
https://github.com/user-attachments/assets/5c88e42e-d5d5-4ddc-9fde-0ef97db531bc
- 主要语言
- Swift
- 星标
- 23k
- 派生
- 1.2k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CodeEditApp/CodeEdit 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
CodeEditApp/CodeEdit#2190 ·
-
难度 1/5 1 小时以内 新手友好度 15/100
CodeEditApp/CodeEdit#2195 · 5 个 reaction ·
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
CodeEditApp/CodeEdit#2185 ·
-
难度 5/5 一周以上 新手友好度 25/100
CodeEditApp/CodeEdit#2181 ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
CodeEditApp/CodeEdit#2180 ·
查看 CodeEditApp/CodeEdit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
maxgoedjen/secretive#840 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
manaflow-ai/cmux#13763 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
openwallet-foundation/multipaz#2028 ·