NodePath Navigation in Script Editor ("Go to Node")#119981
Open
filipemrabreu wants to merge 1 commit into
Open
NodePath Navigation in Script Editor ("Go to Node")#119981filipemrabreu wants to merge 1 commit into
filipemrabreu wants to merge 1 commit into
Conversation
This feature adds IDE-style "Go to Definition" support
for static NodePaths inside the Script Editor. When the
user Ctrl+Clicks a NodePath such as $Node/LineEdit or
get_node("UI/HUD/HealthBar"), the editor resolves the
path relative to the script owner and automatically
selects the matching node in the Scene Tree.
If multiple valid matches exist because the same script
is attached to multiple scene instances, a popup is
shown so the user can choose the intended target.
Dynamic NodePaths such as get_node(path_var) are
excluded from the initial scope to keep the
implementation simpler and more reliable.
Example:
NodeA (Script X.gd)
--- Node/LineEdit
NodeB (Script X.gd)
--- Node/LineEdit
Ctrl+Clicking $Node/LineEdit would display a popup
listing both possible destinations.
Co-authored-by: Joana Vaz <joana.catarina.fernandes.vaz@tecnico.ulisboa.pt>
Member
|
Did you use AI tools in any part of this PR? See our PR policy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature Preview
Feature.mp4
Motivation
In large projects, NodePaths are used to reference nodes across scenes and scripts. However, navigating from these references to the actual node in the Scene Tree currently requires manual searching.
This PR introduces direct navigation support for NodePaths in the Script Editor, allowing users to jump from code references directly to the corresponding node in the Scene Tree. This brings an IDE-like experience (similar to Go to Definition) into the editor, improving navigation efficiency in medium to large-scale projects.
This feature was previously discussed in:
godotengine/godot-proposals#14224
Implementation Overview
The feature is implemented in two main layers:
1. NodePath Detection (CodeEdit)
This layer extracts NodePath expressions from the script text at the current cursor position.
It performs a line-based analysis to identify supported NodePath usages:
$Node/Childshorthand syntaxget_node("Node/Child")callsMatched expressions are forwarded to the navigation system for resolution.
2. Navigation & Resolution (ScriptTextEditor)
This layer is responsible for resolving NodePath expressions and performing the corresponding navigation within the editor.
NodePaths extracted from the script are resolved against the current scene context, producing one or more candidate nodes in the SceneTree. These results are then used to determine how navigation is performed.
Resolution result handling: