Fix panic when accepting completions (#11762)
Release Notes: - Fixed a panic caused by missing bounds check in completion handler
This commit is contained in:
parent
bc292186cd
commit
cf97b995b2
1 changed files with 5 additions and 6 deletions
|
@ -4670,12 +4670,11 @@ impl Editor {
|
||||||
delta +=
|
delta +=
|
||||||
snippet.text.len() as isize - insertion_range.len() as isize;
|
snippet.text.len() as isize - insertion_range.len() as isize;
|
||||||
|
|
||||||
let start = snapshot.anchor_before(
|
let start = ((insertion_start + tabstop_range.start) as usize)
|
||||||
(insertion_start + tabstop_range.start) as usize,
|
.min(snapshot.len());
|
||||||
);
|
let end = ((insertion_start + tabstop_range.end) as usize)
|
||||||
let end = snapshot
|
.min(snapshot.len());
|
||||||
.anchor_after((insertion_start + tabstop_range.end) as usize);
|
snapshot.anchor_before(start)..snapshot.anchor_after(end)
|
||||||
start..end
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue