Skip to content

Commit

Permalink
fix: Don't add \ before {
Browse files Browse the repository at this point in the history
The LSP snippet grammar only specifies that `$`, `}`, and `\` can be escaped with
backslashes, but not `{`.
  • Loading branch information
DropDemBits committed Feb 20, 2024
1 parent 4760d85 commit 7c5758d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/rust-analyzer/src/lsp/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ fn merge_text_and_snippet_edits(

// find which snippet bits need to be escaped
let escape_places = new_text
.rmatch_indices(['\\', '$', '{', '}'])
.rmatch_indices(['\\', '$', '}'])
.map(|(insert, _)| insert)
.collect_vec();
let mut escape_places = escape_places.into_iter().peekable();
Expand Down Expand Up @@ -2176,7 +2176,7 @@ fn bar(_: usize) {}
character: 0,
},
},
new_text: "\\$${1:ab\\{\\}\\$c\\\\d}ef",
new_text: "\\$${1:ab{\\}\\$c\\\\d}ef",
insert_text_format: Some(
Snippet,
),
Expand Down Expand Up @@ -2272,7 +2272,7 @@ struct ProcMacro {
character: 5,
},
},
new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}",
new_text: "$0disabled = false;\n ProcMacro {\n disabled,\n \\}",
insert_text_format: Some(
Snippet,
),
Expand Down Expand Up @@ -2336,7 +2336,7 @@ struct P {
character: 5,
},
},
new_text: "$0disabled = false;\n ProcMacro \\{\n disabled,\n \\}",
new_text: "$0disabled = false;\n ProcMacro {\n disabled,\n \\}",
insert_text_format: Some(
Snippet,
),
Expand Down Expand Up @@ -2401,7 +2401,7 @@ struct ProcMacro {
character: 5,
},
},
new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}",
new_text: "${0:disabled} = false;\n ProcMacro {\n disabled,\n \\}",
insert_text_format: Some(
Snippet,
),
Expand Down Expand Up @@ -2466,7 +2466,7 @@ struct P {
character: 5,
},
},
new_text: "${0:disabled} = false;\n ProcMacro \\{\n disabled,\n \\}",
new_text: "${0:disabled} = false;\n ProcMacro {\n disabled,\n \\}",
insert_text_format: Some(
Snippet,
),
Expand Down

0 comments on commit 7c5758d

Please sign in to comment.