Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Limit BufferSnapshot::surrounding_word search to 256 characters (#32016)
Anthony Eid81f8e2ed4aea
diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rsindex 2d298ff24bd..ef7a22d7e71 100644--- a/crates/language/src/buffer.rs+++ b/crates/language/src/buffer.rs@@ -3283,8 +3283,8 @@ impl BufferSnapshot {pub fn surrounding_word<T: ToOffset>(&self, start: T) -> (Range<usize>, Option<CharKind>) {let mut start = start.to_offset(self);let mut end = start;- let mut next_chars = self.chars_at(start).peekable();- let mut prev_chars = self.reversed_chars_at(start).peekable();+ 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 word_kind = cmp::max(