aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorhi-rustin <[email protected]>2021-05-14 10:30:00 +0100
committerhi-rustin <[email protected]>2021-05-14 10:47:16 +0100
commit765ccf2eca2c21af4e2d76b006809446d0034bc7 (patch)
tree08d457f7e9e401200c72d9de3ff9bb6b221fb09c /crates/ide/src/syntax_highlighting
parentb98c119ba690afdcd21edb3b344834e42422df0a (diff)
Address comments
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs6
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlighting.html11
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs11
3 files changed, 25 insertions, 3 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index bea506544..baed8e217 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -227,8 +227,8 @@ pub(super) fn element(
227 k if k.is_keyword() => { 227 k if k.is_keyword() => {
228 let h = Highlight::new(HlTag::Keyword); 228 let h = Highlight::new(HlTag::Keyword);
229 match k { 229 match k {
230 T![await] 230 T![await] => h | HlMod::Async | HlMod::ControlFlow,
231 | T![break] 231 T![break]
232 | T![continue] 232 | T![continue]
233 | T![else] 233 | T![else]
234 | T![if] 234 | T![if]
@@ -255,7 +255,7 @@ pub(super) fn element(
255 }) 255 })
256 .map(|modifier| h | modifier) 256 .map(|modifier| h | modifier)
257 .unwrap_or(h), 257 .unwrap_or(h),
258 T![async] | T![await] => h | HlMod::Async, 258 T![async] => h | HlMod::Async,
259 _ => h, 259 _ => h,
260 } 260 }
261 } 261 }
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
index df4192194..33bc6b0f3 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
@@ -234,4 +234,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
234 <span class="variable declaration">Nope</span> <span class="operator">=&gt;</span> <span class="variable">Nope</span><span class="comma">,</span> 234 <span class="variable declaration">Nope</span> <span class="operator">=&gt;</span> <span class="variable">Nope</span><span class="comma">,</span>
235 <span class="brace">}</span> 235 <span class="brace">}</span>
236 <span class="brace">}</span> 236 <span class="brace">}</span>
237<span class="brace">}</span>
238
239<span class="keyword async">async</span> <span class="keyword">fn</span> <span class="function declaration async">learn_and_sing</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
240 <span class="keyword">let</span> <span class="variable declaration">song</span> <span class="operator">=</span> <span class="unresolved_reference">learn_song</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="operator">.</span><span class="keyword control async">await</span><span class="semicolon">;</span>
241 <span class="unresolved_reference">sing_song</span><span class="parenthesis">(</span><span class="variable consuming">song</span><span class="parenthesis">)</span><span class="operator">.</span><span class="keyword control async">await</span><span class="semicolon">;</span>
242<span class="brace">}</span>
243
244<span class="keyword async">async</span> <span class="keyword">fn</span> <span class="function declaration async">async_main</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
245 <span class="keyword">let</span> <span class="variable declaration">f1</span> <span class="operator">=</span> <span class="function async">learn_and_sing</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
246 <span class="keyword">let</span> <span class="variable declaration">f2</span> <span class="operator">=</span> <span class="unresolved_reference">dance</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
247 futures::<span class="macro">join!</span><span class="parenthesis">(</span>f1<span class="comma">,</span> f2<span class="parenthesis">)</span><span class="semicolon">;</span>
237<span class="brace">}</span></code></pre> \ No newline at end of file 248<span class="brace">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index b6e952b08..32f2d9038 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -208,6 +208,17 @@ impl<T> Option<T> {
208 } 208 }
209 } 209 }
210} 210}
211
212async fn learn_and_sing() {
213 let song = learn_song().await;
214 sing_song(song).await;
215}
216
217async fn async_main() {
218 let f1 = learn_and_sing();
219 let f2 = dance();
220 futures::join!(f1, f2);
221}
211"# 222"#
212 .trim(), 223 .trim(),
213 expect_file!["./test_data/highlighting.html"], 224 expect_file!["./test_data/highlighting.html"],