aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide/src/syntax_highlighting/injector.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ide/src/syntax_highlighting/injector.rs b/crates/ide/src/syntax_highlighting/injector.rs
index 0513a9fd6..e8f17eb69 100644
--- a/crates/ide/src/syntax_highlighting/injector.rs
+++ b/crates/ide/src/syntax_highlighting/injector.rs
@@ -17,17 +17,15 @@ impl Injector {
17 pub(super) fn add(&mut self, text: &str, source_range: TextRange) { 17 pub(super) fn add(&mut self, text: &str, source_range: TextRange) {
18 let len = TextSize::of(text); 18 let len = TextSize::of(text);
19 assert_eq!(len, source_range.len()); 19 assert_eq!(len, source_range.len());
20 20 self.add_impl(text, Some(source_range.start()));
21 let target_range = TextRange::at(TextSize::of(&self.buf), len);
22 self.ranges
23 .push((target_range, Some(Delta::new(target_range.start(), source_range.start()))));
24 self.buf.push_str(text);
25 } 21 }
26 pub(super) fn add_unmapped(&mut self, text: &str) { 22 pub(super) fn add_unmapped(&mut self, text: &str) {
23 self.add_impl(text, None);
24 }
25 fn add_impl(&mut self, text: &str, source: Option<TextSize>) {
27 let len = TextSize::of(text); 26 let len = TextSize::of(text);
28
29 let target_range = TextRange::at(TextSize::of(&self.buf), len); 27 let target_range = TextRange::at(TextSize::of(&self.buf), len);
30 self.ranges.push((target_range, None)); 28 self.ranges.push((target_range, source.map(|it| Delta::new(target_range.start(), it))));
31 self.buf.push_str(text); 29 self.buf.push_str(text);
32 } 30 }
33 31