Fix panic when accepting completions (#11762)

Release Notes:

- Fixed a panic caused by missing bounds check in completion handler
This commit is contained in:
Conrad Irwin 2024-05-13 13:24:54 -04:00 committed by GitHub
parent bc292186cd
commit cf97b995b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4670,12 +4670,11 @@ impl Editor {
delta +=
snippet.text.len() as isize - insertion_range.len() as isize;
let start = snapshot.anchor_before(
(insertion_start + tabstop_range.start) as usize,
);
let end = snapshot
.anchor_after((insertion_start + tabstop_range.end) as usize);
start..end
let start = ((insertion_start + tabstop_range.start) as usize)
.min(snapshot.len());
let end = ((insertion_start + tabstop_range.end) as usize)
.min(snapshot.len());
snapshot.anchor_before(start)..snapshot.anchor_after(end)
})
})
.collect::<Vec<_>>();