language: Add auto-surround for Plain Text, JSON, and JSONC (#42631)
**Summary**
When users selected text and pressed opening brackets (`(`, `[`, `{`),
the text was deleted instead of being wrapped.
- Added bracket pairs: `()`, `[]`, `{}`, `""`, `''` with `surround =
true`
- Added `surround = true` to existing bracket pairs
- Added `()` bracket pair
**Production Build Fix** (`crates/languages/src/lib.rs`)
- Fixed bug where `brackets` config was stripped in non-`load-grammars`
builds
- Preserved `brackets: config.brackets` in production mode
Closes #41186
**Screen recording**
https://github.com/user-attachments/assets/22067fe7-d5c4-4a72-a93d-8dbaae640168
Release Notes:
- N/A *or* Added/Fixed/Improved ...
---------
Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
co-authored by
Smit Barmase
parent
b79d92d1c6
commit
abf90cc274
@@ -4,9 +4,10 @@ path_suffixes = ["json", "flake.lock"]
|
||||
line_comments = ["// "]
|
||||
autoclose_before = ",]}"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
|
||||
{ start = "{", end = "}", close = true, surround = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, surround = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, surround = true, newline = false },
|
||||
{ start = "\"", end = "\"", close = true, surround = true, newline = false, not_in = ["string"] },
|
||||
]
|
||||
tab_size = 2
|
||||
prettier_parser_name = "json"
|
||||
|
||||
@@ -4,9 +4,10 @@ path_suffixes = ["jsonc", "bun.lock", "tsconfig.json", "pyrightconfig.json"]
|
||||
line_comments = ["// "]
|
||||
autoclose_before = ",]}"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
|
||||
{ start = "{", end = "}", close = true, surround = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, surround = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, surround = true, newline = false },
|
||||
{ start = "\"", end = "\"", close = true, surround = true, newline = false, not_in = ["string"] },
|
||||
]
|
||||
tab_size = 2
|
||||
prettier_parser_name = "jsonc"
|
||||
|
||||
Reference in New Issue
Block a user