Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Instantly update live search #1046

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joliss
Copy link

@joliss joliss commented Aug 17, 2018

Description of the Change

This change causes find-and-replace to react instantly to keystrokes in the findEditor (the "Find in current buffer" field), rather than after a 300ms debounce delay.

This is especially important when the scrollToResultOnLiveSearch setting is enabled, as it lets you instantly see when you're at the right place in the file, just like when you search a web page in Chrome.

Alternate Designs

One could make this behavior changeable with a setting. But I'm not sure if that's even necessary.

Benefits

Search feels snappier.

Possible Drawbacks

I haven't tested the performance impact of this with large buffers or on slower CPUs. We wouldn't want the editor to become unresponsive as you type into the search field.

Applicable Issues

When I tried running the test suite I had some failing tests on master, so I'm not sure if this broke any tests.

This change causes find-and-replace to react instantly to keystrokes in
the `findEditor` (the "Find in current buffer" field), rather than after
a 300ms debounce delay.
@joliss joliss changed the title Instantly update live search. Instantly update live search Aug 17, 2018
@Aerijo
Copy link
Contributor

Aerijo commented Aug 18, 2018

Instant update feels good, but it makes typing noticably slower with many matches (e.g., 20 000). I think work needs to be put into handling the many matches case first, before this can be merged.

Alternatively:

  • There could be a mechanism to switch between delay and no delay, based on number of matches

  • A custom delay time could be used, so it's faster than onDidStopChanging, which is used for more than just find and replace, but slow enough to let the user type.

@maxbrunsfeld
Copy link
Contributor

I think that what we ultimately need to do is a two-step process:

  • In an onDidChange callback, search the visible area. If there are no visible results after the cursor, find the next visible result for the purpose of supporting scrollToResultOnLiveSearch.
  • Then, in an onDidStopChanging callback, search the entire buffer, in order to compute the result count and the Result n of m message.

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

Successfully merging this pull request may close these issues.

3 participants