aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-01-09 13:07:41 +0000
committerAleksey Kladov <[email protected]>2021-01-09 13:07:41 +0000
commit4a8d2c098d88da6f36f3cf95f424b471987c5daa (patch)
treea007952a8870e4d8c0b5fa1e0e0a088b399a8c8d /crates/ide/src/syntax_highlighting
parent62b17bac92595d384aaeb0a0fdc5c03269a0dbac (diff)
Better highlight for fixtures
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r--crates/ide/src/syntax_highlighting/injection.rs4
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/injection.html4
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/ide/src/syntax_highlighting/injection.rs b/crates/ide/src/syntax_highlighting/injection.rs
index de2180b04..008d5ce24 100644
--- a/crates/ide/src/syntax_highlighting/injection.rs
+++ b/crates/ide/src/syntax_highlighting/injection.rs
@@ -42,6 +42,10 @@ pub(super) fn highlight_injection(
42 offset += TextSize::of(chunk); 42 offset += TextSize::of(chunk);
43 43
44 if let Some(next) = text.strip_prefix(marker) { 44 if let Some(next) = text.strip_prefix(marker) {
45 if let Some(range) = literal.map_range_up(TextRange::at(offset, TextSize::of(marker))) {
46 hl.add(HlRange { range, highlight: HlTag::Keyword.into(), binding_hash: None });
47 }
48
45 text = next; 49 text = next;
46 50
47 let marker_len = TextSize::of(marker); 51 let marker_len = TextSize::of(marker);
diff --git a/crates/ide/src/syntax_highlighting/test_data/injection.html b/crates/ide/src/syntax_highlighting/test_data/injection.html
index a54d303b4..6703a84e5 100644
--- a/crates/ide/src/syntax_highlighting/test_data/injection.html
+++ b/crates/ide/src/syntax_highlighting/test_data/injection.html
@@ -40,9 +40,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
40<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> 40<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
41 <span class="function">f</span><span class="punctuation">(</span><span class="string_literal">r"</span> 41 <span class="function">f</span><span class="punctuation">(</span><span class="string_literal">r"</span>
42<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> 42<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
43 <span class="function">foo</span><span class="punctuation">(</span>$0<span class="punctuation">{</span> 43 <span class="function">foo</span><span class="punctuation">(</span><span class="keyword">$0</span><span class="punctuation">{</span>
44 <span class="numeric_literal">92</span> 44 <span class="numeric_literal">92</span>
45 <span class="punctuation">}</span>$0<span class="punctuation">)</span> 45 <span class="punctuation">}</span><span class="keyword">$0</span><span class="punctuation">)</span>
46<span class="punctuation">}</span><span class="string_literal">"</span><span class="punctuation">)</span><span class="punctuation">;</span> 46<span class="punctuation">}</span><span class="string_literal">"</span><span class="punctuation">)</span><span class="punctuation">;</span>
47<span class="punctuation">}</span> 47<span class="punctuation">}</span>
48 </code></pre> \ No newline at end of file 48 </code></pre> \ No newline at end of file