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 12:09:44 -08:00 committed by GitHub
parent afb253b406
commit 492ca219d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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();