Skip to content

Commit 2ef8a62

Browse files
committed
Auto merge of #16618 - DropDemBits:structured-snippet-fix-escape-left-curly, r=Veykril
fix: Don't add `\` before `{` Fixes #16607 for `{`. The `}` case is already fixed by #16475. The [LSP snippet grammar](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) only specifies that `$`, `}`, and `\` can be escaped with backslashes, but not `{`.
2 parents 4760d85 + 825fd70 commit 2ef8a62

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/rust-analyzer/src/lsp/to_proto.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ fn merge_text_and_snippet_edits(
10031003

10041004
// find which snippet bits need to be escaped
10051005
let escape_places = new_text
1006-
.rmatch_indices(['\\', '$', '{', '}'])
1006+
.rmatch_indices(['\\', '$', '}'])
10071007
.map(|(insert, _)| insert)
10081008
.collect_vec();
10091009
let mut escape_places = escape_places.into_iter().peekable();
@@ -2176,7 +2176,7 @@ fn bar(_: usize) {}
21762176
character: 0,
21772177
},
21782178
},
2179-
new_text: "\\$${1:ab\\{\\}\\$c\\\\d}ef",
2179+
new_text: "\\$${1:ab{\\}\\$c\\\\d}ef",
21802180
insert_text_format: Some(
21812181
Snippet,
21822182
),
@@ -2272,7 +2272,7 @@ struct ProcMacro {
22722272
character: 5,
22732273
},
22742274
},
2275-
new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}",
2275+
new_text: "$0disabled = false;\n ProcMacro {\n disabled,\n \\}",
22762276
insert_text_format: Some(
22772277
Snippet,
22782278
),
@@ -2336,7 +2336,7 @@ struct P {
23362336
character: 5,
23372337
},
23382338
},
2339-
new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}",
2339+
new_text: "$0disabled = false;\n ProcMacro {\n disabled,\n \\}",
23402340
insert_text_format: Some(
23412341
Snippet,
23422342
),
@@ -2401,7 +2401,7 @@ struct ProcMacro {
24012401
character: 5,
24022402
},
24032403
},
2404-
new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}",
2404+
new_text: "${0:disabled} = false;\n ProcMacro {\n disabled,\n \\}",
24052405
insert_text_format: Some(
24062406
Snippet,
24072407
),
@@ -2466,7 +2466,7 @@ struct P {
24662466
character: 5,
24672467
},
24682468
},
2469-
new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}",
2469+
new_text: "${0:disabled} = false;\n ProcMacro {\n disabled,\n \\}",
24702470
insert_text_format: Some(
24712471
Snippet,
24722472
),

0 commit comments

Comments
 (0)