Fix panic in autoclosing (#21482)

Closes #14961

Release Notes:

- Fixed a panic when backspacing at the start of a buffer with
`always_treat_brackets_as_autoclosed` enabled.
This commit is contained in:
Conrad Irwin
2024-12-03 13:09:44 -07:00
committed by GitHub
parent afb253b406
commit 492ca219d3
+4 -2
View File
@@ -4098,8 +4098,10 @@ impl Editor {
if buffer.contains_str_at(selection.start, &pair.end) {
let pair_start_len = pair.start.len();
if buffer.contains_str_at(selection.start - pair_start_len, &pair.start)
{
if buffer.contains_str_at(
selection.start.saturating_sub(pair_start_len),
&pair.start,
) {
selection.start -= pair_start_len;
selection.end += pair.end.len();