Skip to content

NodePath Navigation in Script Editor ("Go to Node")#119981

Open
filipemrabreu wants to merge 1 commit into
godotengine:masterfrom
filipemrabreu:go_to_node_script
Open

NodePath Navigation in Script Editor ("Go to Node")#119981
filipemrabreu wants to merge 1 commit into
godotengine:masterfrom
filipemrabreu:go_to_node_script

Conversation

@filipemrabreu
Copy link
Copy Markdown
Contributor

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/Child shorthand syntax
  • get_node("Node/Child") calls

Matched 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:

  • Single match: The target node is selected and focused in the Scene Tree
  • Multiple matches: A selection popup is presented to disambiguate between valid targets
  • No matches: A warning is shown

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>
@AThousandShips
Copy link
Copy Markdown
Member

Did you use AI tools in any part of this PR? See our PR policy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants