search: Fix sort order not being maintained in presence of open buffers#44135
Merged
search: Fix sort order not being maintained in presence of open buffers#44135
Conversation
In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes #43672 Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
7fef84f to
cdfe927
Compare
Contributor
Author
|
/cherry-pick preview |
github-actions bot
pushed a commit
that referenced
this pull request
Dec 4, 2025
…rs (#44135) In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes #43672 Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Release Notes: - Fixed "Select next match" in project search results misbehaving when some of the buffers within the search results were open before search was ran. - Fixed project search results being scrolled to the last file active prior to running the search. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit <smit@zed.dev>
zed-zippy bot
added a commit
that referenced
this pull request
Dec 4, 2025
…rs (#44135) (cherry-pick to preview) (#44138) Cherry-pick of #44135 to preview ---- In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes #43672 Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Release Notes: - Fixed "Select next match" in project search results misbehaving when some of the buffers within the search results were open before search was ran. - Fixed project search results being scrolled to the last file active prior to running the search. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit <smit@zed.dev> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit <smit@zed.dev>
baldwindavid
added a commit
to baldwindavid/zed
that referenced
this pull request
Dec 4, 2025
* main: (155 commits) Add support for git remotes (zed-industries#42819) python: Improve sorting order of toolchains to give higher precedence to project-local virtual environments that are within current subproject (zed-industries#44141) Use buffer language when formatting with Prettier (zed-industries#43368) search: Fix sort order not being maintained in presence of open buffers (zed-industries#44135) bedrock: Support global endpoints and new regional endpoints (zed-industries#44103) linux: Spawn at least two background threads (zed-industries#44110) macos: Add missing file access entitlements (zed-industries#43609) Re-colorize the brackets when the theme changes (zed-industries#44130) Reduce priority of Windows thread pool work items (zed-industries#44121) Update fancy-regex (zed-industries#44120) Prefer to disable options over hiding (git panel entry context menu) (zed-industries#44102) tab_switcher: Subscribe to workspace events instead of pane events (zed-industries#44101) editor: Add active match highlight for buffer and project search (zed-industries#44098) Add more preview tab settings and fix janky behavior (zed-industries#43921) ai: Add an eval for the inline assistant (zed-industries#43291) Fix circular reference issue around PopoverMenu again (zed-industries#44084) Run `git2::Repository::find_remote` in the background (zed-industries#44092) Improve support for multiple registrations of `textDocument/diagnostic` (zed-industries#43703) Revert "http_client: Add integrity checks for GitHub binaries using digest checks (zed-industries#43737)" (zed-industries#44086) editor: Fix blame hover not working when inline git blame is disabled (zed-industries#42992) ...
AlpSha
pushed a commit
to AlpSha/zed
that referenced
this pull request
Dec 5, 2025
…rs (zed-industries#44135) In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes zed-industries#43672 Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Release Notes: - Fixed "Select next match" in project search results misbehaving when some of the buffers within the search results were open before search was ran. - Fixed project search results being scrolled to the last file active prior to running the search. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit <smit@zed.dev>
CherryWorm
pushed a commit
to CherryWorm/zed
that referenced
this pull request
Dec 16, 2025
…rs (zed-industries#44135) In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes zed-industries#43672 Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Release Notes: - Fixed "Select next match" in project search results misbehaving when some of the buffers within the search results were open before search was ran. - Fixed project search results being scrolled to the last file active prior to running the search. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit <smit@zed.dev>
someone13574
pushed a commit
to someone13574/zed
that referenced
this pull request
Dec 16, 2025
…rs (zed-industries#44135) In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes zed-industries#43672 Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Release Notes: - Fixed "Select next match" in project search results misbehaving when some of the buffers within the search results were open before search was ran. - Fixed project search results being scrolled to the last file active prior to running the search. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit <smit@zed.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In project search UI code we were seeing an issue where "Go to next
match" would act up and behave weirdly. It would not wrap at times.
Stuff would be weird, yo. It turned out that match ranges reported by
core project search were sometimes out of sync with the state of the
multi-buffer. As in, the sort order of
search::ProjectSearch::match_rangeswould not match up withmulti-buffer's sort order. This is ~because multi-buffers maintain their
own sort order.
What happened within project search is that we were skipping straight
from stage 1 (filtering paths) to stage 3 via an internal channel and in
the process we've dropped the channel used to maintain result sorting.
This made is so that, given 2 files to scan:
to stage3 (finding all matches) We would report matches for
project/file2.rs first, because we would notice that there's an
existing language::Buffer for it. However, we should wait for
project/file1.rs status to be reported first before we kick off
project/file2.rs
The fix is to use the sorting channel instead of an internal one, as
that keeps the sorting worker "in the loop" about the state of the
world.
Closes #43672
Co-authored-by: Smit Barmase heysmitbarmase@gmail.com
Release Notes: