helix
helix copied to clipboard
search buffer contents during global search
Followup to #5639, addresses https://github.com/helix-editor/helix/issues/5604#issuecomment-1399674583
Currently, helix always queries the FS when performing global search. However, when previewing and opening a file helix automatically uses the buffer if it's already open. That means that the search would report incorrect results for unsaved buffers (which lead to crashes prior to #5639).
This PR creates am implementation of std::io::Read
for Rope
, so we can easily reuse the existing API in grep_searcher
.
This change has the nice side effect of avoiding IO for already open buffers for global search. The performance difference will rarely matter in practice, but it's a nice boost when a huge file is already open in helix. A similar mechanism can be used for #5645 so that files that are changed but unsaved also get reported as changed.
Closes #4207
Slightly unrelated to the PR, but wanted to check if my understanding of the UnboundedReceiverStream is correct.
In the asynchronous callback show_picker
, do we have to worry about the UnboundedReceiverStream
not collecting any values (because all the all_matches_sx
from earlier have been dropped)? In WalkerBuilder.run(), inside the Box, in the definition of sink
, there is a reference to all_matches_sx, so it won't be dropped. Is this why we don't have to worry about the UnboundedReceiverStream closing early?