Search is highly generic, editor is the only implementation that has a concept of a cursor. When the cursor moves eventually `Editor::selections_did_change` runs which among a bunch of things triggers the `SearchEvent::ActiveMatchChanged`. This was handled by the `BufferSearchBar` by moving the currently highlighted item. When going to the next search result (from the cursor position) we call `BufferSearchBar::match_index_for_direction`. It relied on the current_index being updated during the handling of `ActiveMatchChanged` which we removed. It now instead figures out the next/prev search result from the users cursor in the buffer directly. The `SearchEvent::ActiveMatchChanged` was being used for different responsibilities in different places in the codebase where it was emmited, namely: * On the `editor::Editor::selections_did_change` it was being emmited in case a single selection (single cursor) existed, and this was the thing reponsible for indirectly updating the active match as soon as the cursor moved out of match. * On the `terminal` side, it's being emitted when the user clicks on the terminal, to "simulate" what the cursor position would be and update the active match to the next closes match compared to the click position. * On the `markdown_preview` side it was being emmited whenever the active match was updated but, from testing, it does actually seem to not drive anything and is unnecessary? Given that we no longer want to update the active match in the buffer everytime the user moves the cursor, we removed the event emission from `editor::Editor::selections_did_change` as well as removing the one from `markdown_preview`, as it seems it doesn't have any noticeable impact. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #44367 Release Notes: - Fixed search highlighting changing anytime the cursor moves. --------- Co-authored-by: Yara <git@yara.blue>
4 files changedLine totals unavailable