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:
Tim Masliuchenko 2024-03-20 08:35:42 +00:00 committed by GitHub
parent d5e0817fbc
commit 7855b9e9a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 313 additions and 17 deletions

View file

@ -380,6 +380,26 @@ To override settings for a language, add an entry for that language server's nam
`boolean` values
## Always Treat Brackets As Autoclosed
- Description: Controls how the editor handles the autoclosed characters.
- Setting: `always_treat_brackets_as_autoclosed`
- Default: `false`
**Options**
`boolean` values
**Example**
If the setting is set to `true`:
1. Enter in the editor: `)))`
2. Move the cursor to the start: `^)))`
3. Enter again: `)))`
The result is still `)))` and not `))))))`, which is what it would be by default.
## File Types
- Setting: `file_types`
@ -573,6 +593,8 @@ The following settings can be overridden for each specific language:
- `show_whitespaces`
- `soft_wrap`
- `tab_size`
- `use_autoclose`
- `always_treat_brackets_as_autoclosed`
These values take in the same options as the root-level settings with the same name.