Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Fix double $ sign on completion accept in PHP (#34726)
Smit Barmase1dd470ca48fe
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex c3187f6b511..b8dcdd35e07 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -5451,7 +5451,7 @@ impl Editor {};let (word_replace_range, word_to_exclude) = if let (word_range, Some(CharKind::Word)) =- buffer_snapshot.surrounding_word(buffer_position)+ buffer_snapshot.surrounding_word(buffer_position, false){let word_to_exclude = buffer_snapshot.text_for_range(word_range.clone())@@ -6605,8 +6605,8 @@ impl Editor {}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);+ let (start_word_range, _) = snapshot.surrounding_word(cursor_buffer_position, false);+ let (end_word_range, _) = snapshot.surrounding_word(tail_buffer_position, false);if start_word_range != end_word_range {self.document_highlights_task.take();self.clear_background_highlights::<DocumentHighlightRead>(cx);@@ -22137,7 +22137,7 @@ impl SemanticsProvider for Entity<Project> {// Fallback on using TreeSitter info to determine identifier rangebuffer.read_with(cx, |buffer, _| {let snapshot = buffer.snapshot();- let (range, kind) = snapshot.surrounding_word(position);+ let (range, kind) = snapshot.surrounding_word(position, false);if kind != Some(CharKind::Word) {return None;}diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rsindex ae0184b22a9..59aa63ff380 100644--- a/crates/language/src/buffer.rs+++ b/crates/language/src/buffer.rs@@ -3364,13 +3364,19 @@ impl BufferSnapshot {/// Returns a tuple of the range and character kind of the word/// surrounding the given position.- pub fn surrounding_word<T: ToOffset>(&self, start: T) -> (Range<usize>, Option<CharKind>) {+ pub fn surrounding_word<T: ToOffset>(+ &self,+ start: T,+ for_completion: bool,+ ) -> (Range<usize>, Option<CharKind>) {let mut start = start.to_offset(self);let mut end = start;let mut next_chars = self.chars_at(start).take(128).peekable();let mut prev_chars = self.reversed_chars_at(start).take(128).peekable();- let classifier = self.char_classifier_at(start);+ let classifier = self+ .char_classifier_at(start)+ .for_completion(for_completion);let word_kind = cmp::max(prev_chars.peek().copied().map(|c| classifier.kind(c)),next_chars.peek().copied().map(|c| classifier.kind(c)),diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rsindex 4538dc4cda5..a2f6de44c9c 100644--- a/crates/project/src/lsp_command.rs+++ b/crates/project/src/lsp_command.rs@@ -350,7 +350,7 @@ impl LspCommand for PrepareRename {}Some(lsp::PrepareRenameResponse::DefaultBehavior { .. }) => {let snapshot = buffer.snapshot();- let (range, _) = snapshot.surrounding_word(self.position);+ let (range, _) = snapshot.surrounding_word(self.position, false);let range = snapshot.anchor_after(range.start)..snapshot.anchor_before(range.end);Ok(PrepareRenameResponse::Success(range))}@@ -2297,7 +2297,7 @@ impl LspCommand for GetCompletions {range_for_token.get_or_insert_with(|| {let offset = self.position.to_offset(&snapshot);- let (range, kind) = snapshot.surrounding_word(offset);+ let (range, kind) = snapshot.surrounding_word(offset, true);let range = if kind == Some(CharKind::Word) {range} else {