diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-04 09:30:44 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-04 11:38:09 +0100 |
| commit | eb951c008beea502042db4a3a0e8d1f8b51f6f52 (patch) | |
| tree | 9856ee4ed0222222669de10e616a580b2a60135e /src/syntax/highlight.rs | |
| parent | 33928a00dc58250e24da1dae4e5db17e7b598d70 (diff) | |
Style changes
Diffstat (limited to 'src/syntax/highlight.rs')
| -rw-r--r-- | src/syntax/highlight.rs | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/syntax/highlight.rs b/src/syntax/highlight.rs index 0db45785..d5345fab 100644 --- a/src/syntax/highlight.rs +++ b/src/syntax/highlight.rs @@ -81,7 +81,7 @@ where F: FnMut(Range<usize>, Style), { if node.children().len() == 0 { - let range = offset .. offset + node.len(); + let range = offset..offset + node.len(); let style = highlighter.style_for_stack(&scopes); f(range, style); return; @@ -112,7 +112,7 @@ where F: FnMut(Range<usize>, Category), { for (i, child) in node.children().enumerate() { - let span = offset .. offset + child.len(); + let span = offset..offset + child.len(); if range.start <= span.end && range.end >= span.start { if let Some(category) = Category::determine(child, node, i) { f(span, category); @@ -412,29 +412,35 @@ mod tests { fn test(text: &str, goal: &[(Range<usize>, Category)]) { let mut vec = vec![]; let source = Source::detached(text); - let full = 0 .. text.len(); + let full = 0..text.len(); highlight_categories(source.root(), full, &mut |range, category| { vec.push((range, category)); }); assert_eq!(vec, goal); } - test("= *AB*", &[(0 .. 6, Heading), (2 .. 6, Strong)]); - - test("#f(x + 1)", &[ - (0 .. 2, Function), - (2 .. 3, Bracket), - (5 .. 6, Operator), - (7 .. 8, Number), - (8 .. 9, Bracket), - ]); - - test("#let f(x) = x", &[ - (0 .. 4, Keyword), - (5 .. 6, Function), - (6 .. 7, Bracket), - (8 .. 9, Bracket), - (10 .. 11, Operator), - ]); + test("= *AB*", &[(0..6, Heading), (2..6, Strong)]); + + test( + "#f(x + 1)", + &[ + (0..2, Function), + (2..3, Bracket), + (5..6, Operator), + (7..8, Number), + (8..9, Bracket), + ], + ); + + test( + "#let f(x) = x", + &[ + (0..4, Keyword), + (5..6, Function), + (6..7, Bracket), + (8..9, Bracket), + (10..11, Operator), + ], + ); } } |
