Add better snippet bits test

This commit is contained in:
DropDemBits 2024-02-15 23:29:17 -05:00
parent e9efb568f6
commit e4a3cc34d5
No known key found for this signature in database
GPG Key ID: 7FE02A6C1EDFA075

View File

@ -2145,51 +2145,71 @@ fn snippet_rendering_multiple_placeholders_in_text_edit() {
fn snippet_rendering_escape_snippet_bits() { fn snippet_rendering_escape_snippet_bits() {
// only needed for snippet formats // only needed for snippet formats
let mut edit = TextEdit::builder(); let mut edit = TextEdit::builder();
edit.insert(0.into(), r"abc\def$".to_owned()); edit.insert(0.into(), r"$ab{}$c\def".to_owned());
edit.insert(8.into(), r"ghi\jkl$".to_owned()); edit.insert(8.into(), r"ghi\jk<-check_insert_here$".to_owned());
edit.insert(10.into(), r"a\\b\\c{}$".to_owned());
let edit = edit.finish(); let edit = edit.finish();
let snippets = let snippets = SnippetEdit::new(vec![
SnippetEdit::new(vec![Snippet::Placeholder(TextRange::new(0.into(), 3.into()))]); Snippet::Placeholder(TextRange::new(1.into(), 9.into())),
Snippet::Tabstop(25.into()),
]);
check_rendered_snippets( check_rendered_snippets(
edit, edit,
snippets, snippets,
expect![[r#" expect![[r#"
[ [
SnippetTextEdit { SnippetTextEdit {
range: Range { range: Range {
start: Position { start: Position {
line: 0, line: 0,
character: 0, character: 0,
}, },
end: Position { end: Position {
line: 0, line: 0,
character: 0, character: 0,
},
}, },
new_text: "\\$${1:ab{}\\$c\\\\d}ef",
insert_text_format: Some(
Snippet,
),
annotation_id: None,
}, },
new_text: "${0:abc}\\\\def\\$", SnippetTextEdit {
insert_text_format: Some( range: Range {
Snippet, start: Position {
), line: 0,
annotation_id: None, character: 8,
}, },
SnippetTextEdit { end: Position {
range: Range { line: 0,
start: Position { character: 8,
line: 0, },
character: 8,
},
end: Position {
line: 0,
character: 8,
}, },
new_text: "ghi\\\\jk$0<-check_insert_here\\$",
insert_text_format: Some(
Snippet,
),
annotation_id: None,
}, },
new_text: "ghi\\jkl$", SnippetTextEdit {
insert_text_format: None, range: Range {
annotation_id: None, start: Position {
}, line: 0,
] character: 10,
"#]], },
end: Position {
line: 0,
character: 10,
},
},
new_text: "a\\\\b\\\\c{}$",
insert_text_format: None,
annotation_id: None,
},
]
"#]],
); );
} }