Allow to handle autoclosed characters differently (#8666)
Adds the `always_treat_brackets_as_autoclosed` setting to control how the autoclosed characters are handled. The setting is off by default, meaning the behaviour stays the same (following how VSCode handles autoclosed characters). When set to `true`, the autoclosed characters are always skipped over and auto-removed no matter how they were inserted (following how Sublime Text/Xcode handle this). https://github.com/zed-industries/zed/assets/471335/304cd04a-59fe-450f-9c65-cc31b781b0db https://github.com/zed-industries/zed/assets/471335/0f5b09c2-260f-48d4-8528-23f122dee45f Release Notes: - Added the setting `always_treat_brackets_as_autoclosed` (default: `false`) to always treat brackets as "auto-closed" brackets, i.e. deleting the pair when deleting start/end, etc. ([#7146](https://github.com/zed-industries/zed/issues/7146)). --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
parent
d5e0817fbc
commit
7855b9e9a8
5 changed files with 313 additions and 17 deletions
|
@ -103,6 +103,8 @@ pub struct LanguageSettings {
|
|||
pub inlay_hints: InlayHintSettings,
|
||||
/// Whether to automatically close brackets.
|
||||
pub use_autoclose: bool,
|
||||
// Controls how the editor handles the autoclosed characters.
|
||||
pub always_treat_brackets_as_autoclosed: bool,
|
||||
/// Which code actions to run on save
|
||||
pub code_actions_on_format: HashMap<String, bool>,
|
||||
}
|
||||
|
@ -231,7 +233,14 @@ pub struct LanguageSettingsContent {
|
|||
///
|
||||
/// Default: true
|
||||
pub use_autoclose: Option<bool>,
|
||||
|
||||
// Controls how the editor handles the autoclosed characters.
|
||||
// When set to `false`(default), skipping over and auto-removing of the closing characters
|
||||
// happen only for auto-inserted characters.
|
||||
// Otherwise(when `true`), the closing characters are always skipped over and auto-removed
|
||||
// no matter how they were inserted.
|
||||
///
|
||||
/// Default: false
|
||||
pub always_treat_brackets_as_autoclosed: Option<bool>,
|
||||
/// Which code actions to run on save
|
||||
///
|
||||
/// Default: {} (or {"source.organizeImports": true} for Go).
|
||||
|
@ -602,6 +611,10 @@ fn merge_settings(settings: &mut LanguageSettings, src: &LanguageSettingsContent
|
|||
merge(&mut settings.hard_tabs, src.hard_tabs);
|
||||
merge(&mut settings.soft_wrap, src.soft_wrap);
|
||||
merge(&mut settings.use_autoclose, src.use_autoclose);
|
||||
merge(
|
||||
&mut settings.always_treat_brackets_as_autoclosed,
|
||||
src.always_treat_brackets_as_autoclosed,
|
||||
);
|
||||
merge(&mut settings.show_wrap_guides, src.show_wrap_guides);
|
||||
merge(&mut settings.wrap_guides, src.wrap_guides.clone());
|
||||
merge(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue