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 authored and GitHub committed 2025-04-03 02:00:44 +05:30
1 parent ec4babbf14
commit f86a2847da
1 file changed
+12 -7
+12 -7
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,
});
}
}
}
}