Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use multibuffer to fix symbol search when diff is present (#52268)
Steven810822b5cd81
diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rsindex 84b92f3eaa4..351b6e7afb5 100644--- a/crates/project_symbols/src/project_symbols.rs+++ b/crates/project_symbols/src/project_symbols.rs@@ -1,4 +1,6 @@-use editor::{Bias, Editor, SelectionEffects, scroll::Autoscroll, styled_runs_for_code_label};+use editor::{+ Anchor, Bias, Editor, SelectionEffects, scroll::Autoscroll, styled_runs_for_code_label,+};use fuzzy::{StringMatch, StringMatchCandidate};use gpui::{App, Context, DismissEvent, Entity, HighlightStyle, ParentElement, StyledText, Task, TextStyle,@@ -140,11 +142,19 @@ impl PickerDelegate for ProjectSymbolsDelegate {);editor.update(cx, |editor, cx| {+ let multibuffer_snapshot = editor.buffer().read(cx).snapshot(cx);+ let Some((excerpt_id, _, buffer_snapshot)) =+ multibuffer_snapshot.as_singleton()+ else {+ return;+ };+ let text_anchor = buffer_snapshot.anchor_before(position);+ let anchor = Anchor::in_buffer(excerpt_id, text_anchor);editor.change_selections(SelectionEffects::scroll(Autoscroll::center()),window,cx,- |s| s.select_ranges([position..position]),+ |s| s.select_ranges([anchor..anchor]),);});})?;