Skip to content

Commit

Permalink
Fix panic in autoclosing (#21482)
Browse files Browse the repository at this point in the history
Closes #14961

Release Notes:

- Fixed a panic when backspacing at the start of a buffer with
`always_treat_brackets_as_autoclosed` enabled.
  • Loading branch information
ConradIrwin committed Dec 3, 2024
1 parent 8bf1edf commit 061272b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4142,8 +4142,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();

Expand Down

0 comments on commit 061272b

Please sign in to comment.