Limit BufferSnapshot::surrounding_word search to 256 characters (#32016)

This is the first step to closing #16120. Part of the problem was that
`surrounding_word` would search the whole line for matches with no
limit.

Co-authored-by: Conrad Irwin \<conrad@zed.dev\>
Co-authored-by: Ben Kunkle \<ben@zed.dev\>
Co-authored-by: Cole Miller \<cole@zed.dev\>

Release Notes:

- N/A
This commit is contained in:
Anthony Eid
2025-06-03 21:08:59 +00:00
committed by GitHub
co-authored by Conrad Irwin \<conrad@zed.dev\> Ben Kunkle \<ben@zed.dev\> Cole Miller \<cole@zed.dev\>
parent b9256dd469
commit 81f8e2ed4a
+2 -2
View File
@@ -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(