Skip to content

Improve Find in Files support for built-in resources - #121945

Open
TheDying0fLight wants to merge 1 commit into
godotengine:masterfrom
TheDying0fLight:improve-find-in-files-builtin-support
Open

Improve Find in Files support for built-in resources#121945
TheDying0fLight wants to merge 1 commit into
godotengine:masterfrom
TheDying0fLight:improve-find-in-files-builtin-support

Conversation

@TheDying0fLight

@TheDying0fLight TheDying0fLight commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

Additional information

This PR tries to give search and replace in files decent support for built-in shaders/scripts

Features

  • Correctly opens Shader matches in the shader editor when clicked on
  • No longer opens random scripts when clicking on a result from a tscn which does not belong to a script that can be opened. Added an error messages for this
  • Searches tscn files for Shader/GDScript sub_resource when gd/gdshader is set (even when tscn isn't)
  • Adds resource ids to matches in open scenes
  • Only returns matches in shader/script section in tscn files if the scene is open.

Notes

  • Built-in search only works on scripts that have been saved at least once since Find in Files currently only searches through files on the disk and checks if they are open in editors
  • When searching an open scene only matches for gd and gdshader can be found
  • Moved _on_find_in_files_result_selected to EditorNode and renamed it to edit_text_resource so it can be reused (for example in Show shader editor on shader compilation error #112954)

Scene open

image

Scene closed

image

@AThousandShips AThousandShips added this to the 4.x milestone Jul 31, 2026
@TheDying0fLight
TheDying0fLight force-pushed the improve-find-in-files-builtin-support branch from ad79a92 to fedfc98 Compare July 31, 2026 11:00
@TheDying0fLight
TheDying0fLight marked this pull request as ready for review July 31, 2026 11:00
@TheDying0fLight
TheDying0fLight requested review from a team as code owners July 31, 2026 11:00
@KoBeWi

KoBeWi commented Jul 31, 2026

Copy link
Copy Markdown
Member

Searches tscn files for Shader/GDScript sub_resource when gd/gdshader is set (even when tscn isn't)

That makes searching longer, no?

Built-in search only works on saved data and reloads the scene after replacing (not sure if the used way is the best to reload a scene, it works but closes open editors)

You can fetch Script/Shader resources from ResourceCache using their internal path/ID, and patch them if they exist, similar to #114300

@TheDying0fLight

TheDying0fLight commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

That makes searching longer, no?

Yes. If that is an issue I'd suggest an editor setting which can also be toggled directly in the Find in Files options so users can discover it easily

You can fetch Script/Shader resources from ResourceCache using their internal path/ID, and patch them if they exist, similar to #114300

I tried this but had some issues. Now that I look at it again I have some new ideas to approach it and will look more closely at it tomorrow

@TheDying0fLight
TheDying0fLight force-pushed the improve-find-in-files-builtin-support branch from fedfc98 to 9ad04b5 Compare August 1, 2026 15:43
@TheDying0fLight
TheDying0fLight requested review from a team as code owners August 1, 2026 15:43
@TheDying0fLight

TheDying0fLight commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

You can fetch Script/Shader resources from ResourceCache using their internal path/ID, and patch them if they exist, similar to #114300

I tried this but had some issues. Now that I look at it again I have some new ideas to approach it and will look more closely at it tomorrow

Searching/Replacing now works in Script/Shader resources of an open scene but will not return any other results. I had to adjust is_unsaved and use set_edited(false) in some places to make sure changes in resources not open in an editor are correctly marked as unsaved while avoiding built-in resources to always be marked as unsaved. I'm not 100% sure the set_edited(false) usage doesn't break anything but it should be fine since I use it at places where the resources are loaded (Though I just realized that this needs TOOLS_ENABLED)

@TheDying0fLight
TheDying0fLight force-pushed the improve-find-in-files-builtin-support branch from 9ad04b5 to 1ee6e5d Compare August 1, 2026 15:56
@TheDying0fLight
TheDying0fLight force-pushed the improve-find-in-files-builtin-support branch 3 times, most recently from 97380c1 to 2580f07 Compare August 22, 2026 15:01
@TheDying0fLight
TheDying0fLight force-pushed the improve-find-in-files-builtin-support branch from 2580f07 to 3bd9a52 Compare August 25, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants