godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add a small delay before Find and Replace starts searching for patterns #5361

Open MewPurPur opened 2 years ago

MewPurPur commented 2 years ago

Describe the project you are working on

2D Platformer with some quite big scripts

Describe the problem or limitation you are having in your project

In big scripts, I have all functions folded to navigate more easily. Sometimes I need to search for things inside those functions, and I hit all sorts of unwanted suggestions while typing.

https://user-images.githubusercontent.com/85438892/188762548-1ab5692e-ef9a-4d77-bb08-d51d684b3fe6.mp4

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

  1. Fold functions back after they have been searched over.
  2. As the title suggests, implement a brief delay before performing the search.

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

I think both options outlined above have their merits.

The minor delay would reduce the overhead when the user is typing fast, but would require an implementation of a new Editor Setting, with a default that may be too fast for some and too slow for others. Though we have several such delay settings already and it's not that big of a deal.

The folding one would solve the issue without new editor settings, and would also work when searching over the script for a word that's in several functions. In practice, it might be annoying to not know which functions were folded or unfolded before searching, and "temporarily folded" functions would also need a cue so as to not feel like they fold back without user input.

Nothing stops us from eventually implementing both – I think that would bring the best of both worlds.

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

N/A, this is more of an enhancement

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

Search & Replace should feel good out of the box

Mickeon commented 2 years ago

I feel like this setting could be applied to a lot more than just "Find and Replace". Filtering around the Engine is bare-minimum and not quite optimised, so some machines may experience a short "lock" on the main thread as the filter term is being written.

MewPurPur commented 2 years ago

Good idea. Filtering isn't the same as Search & Replace so I decided to avoid it; If we do that, should we use the same editor setting to customize the delay? Not all filtering is in the code editor so might need to make the setting broader.

Mickeon commented 2 years ago

I would say yes, but what I can't say is how "annoying" it would be for some filters to have this behaviour applied to them (for example, the Inspector filter doesn't really need this, as well as any other filter with a really small scope)

MewPurPur commented 2 years ago

It's a bit weirder, like, there is no benefit other than reducing the overhead. In the case of Find & Replace, typing means the script jumps all around while you're typing and functions get unfolded. For filtering, there isn't any of that.