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

Improve Find/Replace in Files dialog #5544

Open
bitbrain opened this issue Oct 4, 2022 · 7 comments
Open

Improve Find/Replace in Files dialog #5544

bitbrain opened this issue Oct 4, 2022 · 7 comments

Comments

@bitbrain
Copy link

bitbrain commented Oct 4, 2022

Describe the project you are working on

I am working on an Untitled Single-Player 2D RPG where an adventurer explores a giant mountain area (project name: cave). The game consists of procedurally generated levels and custom built levels. All ported over to Godot 4.0! It comes with a lot of files that I am going to search (and replace) across when required:
Capture

This became especially apparent when upgrading to Godot 4.

Describe the problem or limitation you are having in your project

After working on my game for almost 2.5 years I have a lot of files. Searching across all the files becomes cumbersome as it involves the following steps:

  1. click on the Script tab (search not available in 2D/3D node view)
    Capture

  2. Press CTRL+SHIFT+F to open the "Search in files..." dialog and enter search term with a typo
    Capture

  3. It shows 0 results and I have to repeat the process

There are three problems for me with this approach:

Problem 1: too many steps to search what I want. When I am currently in a node somewhere I always have to click into the Script tab first to search across files.

Problem 2: search is not responsive enough. In IDEs such as IntelliJ it is possible to search and get "realtime" results for occurences. In Godot it is quite cumbersome to search because on typos or further searches I have to repeat the above steps.

Problem 3: only gdscript and shaders are supported. This seems to be a general limitation by Godot, as many games also come with .json, .csv or other files (e.g. translations) but I am unable to search across them.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

  • Allow the search dialog to be triggered without requiring the Script tab to be active
  • Show list of results in the dialog itself and let it refresh automatically after finishing typing (example from CLion):
    Capture
  • Allow searching by file extension rather than limiting it to .gd or shader (possibly requires a generic text editor view first)

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

From anywhere within Godot Engine, pressing CTRL+SHIFT+R to open a dialog like this:

search

Once the user starts typing a scrollable list of results appears. Clicking on any result will switch the Godot view to the Script tab and open the file and jump to the affected line.

Optionally, the user can select a file mask (perhaps dropdown or cleartext, e.g. *.txt) to search across other files.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not really. This is a usability feature that would save myself a lot of frustration long-term.

Is there a reason why this should be core and not an add-on in the asset library?

Most of the functionality described here is already Core but not streamlined from a UX perspective. This proposal aims to change that. The only optional functionality could be the filemask as non-Godot files are currently not really supported within the Godot editor.

@Calinou
Copy link
Member

Calinou commented Oct 4, 2022

Problem 3: only gdscript and shaders are supported. This seems to be a general limitation by Godot, as many games also come with .json, .csv or other files (e.g. translations) but I am unable to search across them.

You can change the file extensions that can be searched in the Project Settings.

To avoid the need for this setting, I suppose we could make Godot search in all resource files that are not binary (and exclude .tscn), but detecting this can take some work.

@Calinou Calinou changed the title "IntelliJ" style search (+replace) across all files Improve Find/Replace in Files dialog Oct 4, 2022
@bend-n
Copy link

bend-n commented Oct 4, 2022

Can we rename "file mask" to something like "include paths"? where you can specify the directory's or file types to be searched via globbing?

@EricEzaM
Copy link

EricEzaM commented Oct 17, 2022

I've been working on this a bit. It has been on my list of things I wanted to try for a while now - and I love me some Jetbrains find-replace :) So why not? It has been fun!

godot.windows.editor.dev.x86_64_643FdDrcvj.mp4

image

@bitbrain
Copy link
Author

@EricEzaM any chance you can raise a PR for this?

@EricEzaM
Copy link

Hi @bitbrain, unfortunately I am not in the position to continue work on this feature. My branch is here for anyone who wishes to either continue where I left off or use some of my code in their own implementation. Please note it has not been rebased to latest develop, so if you checkout this branch it will be quite far behind master, and when rebasing it there may be many conflicts.
https://github.com/EricEzaM/godot/tree/better-find-in-files

In the end I got the popup working quite well. I think I got a bit stuck with the performance of the tabbed window in the bottom dock when you requested to see the full results - I think I tried Tree and ItemList and due to the lack of virtualisation performance of the editor was very poor when trying to view 1000+ results. Like JetBrains apps, the popup limited results to 100 rows so it remained very responsive. I implemented the popup which says "there are a lot of results (1000+), are you sure you want to continue the search?", but even if you selected no, and it showed 1000, the UI was basically unusable.

The searching was done by offloading the searching work to a background thread, and there was a thread-safe API to access search status and results. This seemed to work well.

One day I may be able to return to work on this feature again but it likely won't be soon - sorry about that. I guess this is part of the open source experience™ 😂

Cheers

@EricEzaM
Copy link

EricEzaM commented Dec 8, 2023

I've found some time/motivation and I am working on this again. Updates are available on the same branch linked above. It's getting there, but still quite a way to go before being 'done'.

godot.windows.editor.dev.x86_64_UHc4O4f6fA.mp4

@bitbrain
Copy link
Author

bitbrain commented Dec 9, 2023

@EricEzaM would you mind raising a draft PR? This could accellerate the process and you could ask for feedback on implementation details.

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

No branches or pull requests

4 participants