Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Smit Barmase9f9746872ed6
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index cb516c59c11..d1e19a20e97 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -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,
+ });
+ }
}
}
}