helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.45k stars 2.4k forks source link

Buffer search #5597

Open haikyuu opened 1 year ago

haikyuu commented 1 year ago

We currently have / for global search in workspace folder. But searching open buffers is sometimes useful. Maybe map it to [ (for open) to keep close to /.

ontley commented 1 year ago

Is Space-b not enough?

gabydd commented 1 year ago

I believe this issue is about searching the actual text in all the open buffers

ontley commented 1 year ago

Ahh sorry my bad, I might look into actually working on it then

pascalkuthe commented 1 year ago

5652 allows global_search to use the content of buffer instead of reloading buffers from disk (which lead to weird mismatches before).

That PR wraps the helix buffer datat structure (Rope) so it can be effticely searched with grep_searcher. Based on that work it should be pretty easy to add a version that iterates all document instead of using a WalkBuilder (and keep the logic inside the file iteration the same)

rcorre commented 1 year ago

Should you need to type a search term first (similar to space-/), or should it just open a picker right away (similar to space-f, space-S`, etc.) filled with all lines?

I've been missing the latter, which I had in nvim from fzf.vim's :Lines command.

pascalkuthe commented 1 year ago

you need to type the search regex first altough there are efforts to make the regex search incremental, see #4687.

Fuzzy matching on lines instead of performing a regex search could also be interesting but that would probably be a second picker closer to #3462. There are some strong performance caveats with that as it essentially requires loading all files into memory (and keeping them there). I have some ideas how to avoid the issue of cloning each line if the search was constrained to open buffers (or the current) tough. That is probably the more useful application too. However for a feature like that we would want the fuzzy matching to be partially async (so it runs synchronously when fast enough but asynchronously when not, maybe we can come-up with an even smarter strategy).