Skip to content

Commit 614987a

Browse files
committed
Test rendering of snippets
Had a missing ':' between the snippet index and placeholder text
1 parent a1877df commit 614987a

File tree

2 files changed

+489
-13
lines changed

2 files changed

+489
-13
lines changed

crates/ide-db/src/source_change.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl FromIterator<(FileId, TextEdit)> for SourceChange {
133133
pub struct SnippetEdit(Vec<(u32, TextRange)>);
134134

135135
impl SnippetEdit {
136-
fn new(snippets: Vec<Snippet>) -> Self {
136+
pub fn new(snippets: Vec<Snippet>) -> Self {
137137
let mut snippet_ranges = snippets
138138
.into_iter()
139139
.zip(1..)
@@ -157,8 +157,10 @@ impl SnippetEdit {
157157
snippet_ranges.sort_by_key(|(_, range)| range.start());
158158

159159
// Ensure that none of the ranges overlap
160-
let disjoint_ranges =
161-
snippet_ranges.windows(2).all(|ranges| ranges[0].1.end() <= ranges[1].1.start());
160+
let disjoint_ranges = snippet_ranges
161+
.iter()
162+
.zip(snippet_ranges.iter().skip(1))
163+
.all(|((_, left), (_, right))| left.end() <= right.start() || left == right);
162164
stdx::always!(disjoint_ranges);
163165

164166
SnippetEdit(snippet_ranges)
@@ -393,7 +395,7 @@ impl From<FileSystemEdit> for SourceChange {
393395
}
394396
}
395397

396-
enum Snippet {
398+
pub enum Snippet {
397399
/// A tabstop snippet (e.g. `$0`).
398400
Tabstop(TextSize),
399401
/// A placeholder snippet (e.g. `${0:placeholder}`).

0 commit comments

Comments
 (0)