editor: Fix typing closing bracket skips it even when use_autoclose is disabled (#27960)

Closes #27769

When adding snippet we were not respecting autoclose setting, before
creating AutocloseRegion. This leads to cursor to skip over instead of
typing that character. This PR fixes it.

Release Notes:

- Fixed certain case where typing closing bracket would skip it when
auto close setting is turned off.
This commit is contained in:
Smit Barmase 2025-04-03 02:00:44 +05:30 committed by GitHub
parent 01ec6e0f77
commit 9f9746872e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7876,13 +7876,18 @@ impl Editor {
}
}
if let Some(pair) = bracket_pair {
let start = snapshot.anchor_after(selection_head);
let end = snapshot.anchor_after(selection_head);
self.autoclose_regions.push(AutocloseRegion {
selection_id: selection.id,
range: start..end,
pair,
});
let snapshot_settings = snapshot.language_settings_at(selection_head, cx);
let autoclose_enabled =
self.use_autoclose && snapshot_settings.use_autoclose;
if autoclose_enabled {
let start = snapshot.anchor_after(selection_head);
let end = snapshot.anchor_after(selection_head);
self.autoclose_regions.push(AutocloseRegion {
selection_id: selection.id,
range: start..end,
pair,
});
}
}
}
}