diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/html.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 4496529a1..4f17d1040 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Renders a bit of code as HTML. | 1 | //! Renders a bit of code as HTML. |
2 | 2 | ||
3 | use ra_db::SourceDatabase; | 3 | use ra_db::SourceDatabase; |
4 | use ra_syntax::{AstNode, TextUnit}; | 4 | use ra_syntax::{AstNode, TextSize}; |
5 | 5 | ||
6 | use crate::{FileId, RootDatabase}; | 6 | use crate::{FileId, RootDatabase}; |
7 | 7 | ||
@@ -23,17 +23,18 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo | |||
23 | 23 | ||
24 | let ranges = highlight(db, file_id, None); | 24 | let ranges = highlight(db, file_id, None); |
25 | let text = parse.tree().syntax().to_string(); | 25 | let text = parse.tree().syntax().to_string(); |
26 | let mut prev_pos = TextUnit::from(0); | 26 | let mut prev_pos = TextSize::from(0); |
27 | let mut buf = String::new(); | 27 | let mut buf = String::new(); |
28 | buf.push_str(&STYLE); | 28 | buf.push_str(&STYLE); |
29 | buf.push_str("<pre><code>"); | 29 | buf.push_str("<pre><code>"); |
30 | // TODO: unusize | ||
30 | for range in &ranges { | 31 | for range in &ranges { |
31 | if range.range.start() > prev_pos { | 32 | if range.range.start() > prev_pos { |
32 | let curr = &text[prev_pos.to_usize()..range.range.start().to_usize()]; | 33 | let curr = &text[usize::from(prev_pos)..usize::from(range.range.start())]; |
33 | let text = html_escape(curr); | 34 | let text = html_escape(curr); |
34 | buf.push_str(&text); | 35 | buf.push_str(&text); |
35 | } | 36 | } |
36 | let curr = &text[range.range.start().to_usize()..range.range.end().to_usize()]; | 37 | let curr = &text[usize::from(range.range.start())..usize::from(range.range.end())]; |
37 | 38 | ||
38 | let class = range.highlight.to_string().replace('.', " "); | 39 | let class = range.highlight.to_string().replace('.', " "); |
39 | let color = match (rainbow, range.binding_hash) { | 40 | let color = match (rainbow, range.binding_hash) { |
@@ -47,7 +48,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo | |||
47 | prev_pos = range.range.end(); | 48 | prev_pos = range.range.end(); |
48 | } | 49 | } |
49 | // Add the remaining (non-highlighted) text | 50 | // Add the remaining (non-highlighted) text |
50 | let curr = &text[prev_pos.to_usize()..]; | 51 | let curr = &text[usize::from(prev_pos)..]; |
51 | let text = html_escape(curr); | 52 | let text = html_escape(curr); |
52 | buf.push_str(&text); | 53 | buf.push_str(&text); |
53 | buf.push_str("</code></pre>"); | 54 | buf.push_str("</code></pre>"); |