Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Do not show document highlights when selection is spanned more than word (#30602)
Smit Barmase229f3dab22ea
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 0e4be2058c0..7d675aa5af9 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -5758,10 +5758,22 @@ impl Editor {let cursor_position = newest_selection.head();let (cursor_buffer, cursor_buffer_position) =buffer.text_anchor_for_position(cursor_position, cx)?;- let (tail_buffer, _) = buffer.text_anchor_for_position(newest_selection.tail(), cx)?;+ let (tail_buffer, tail_buffer_position) =+ buffer.text_anchor_for_position(newest_selection.tail(), cx)?;if cursor_buffer != tail_buffer {return None;}++ let snapshot = cursor_buffer.read(cx).snapshot();+ let (start_word_range, _) = snapshot.surrounding_word(cursor_buffer_position);+ let (end_word_range, _) = snapshot.surrounding_word(tail_buffer_position);+ if start_word_range != end_word_range {+ self.document_highlights_task.take();+ self.clear_background_highlights::<DocumentHighlightRead>(cx);+ self.clear_background_highlights::<DocumentHighlightWrite>(cx);+ return None;+ }+let debounce = EditorSettings::get_global(cx).lsp_highlight_debounce;self.document_highlights_task = Some(cx.spawn(async move |this, cx| {cx.background_executor()