Skip to content

Commit

Permalink
Add comments for why skip highlighting for invalid char/byte literals
Browse files Browse the repository at this point in the history
  • Loading branch information
oxalica committed Jul 22, 2023
1 parent 1f35e4d commit 51b35cc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/ide/src/syntax_highlighting/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub(super) fn highlight_escape_string<T: IsString>(

pub(super) fn highlight_escape_char(stack: &mut Highlights, char: &Char, start: TextSize) {
if char.value().is_none() {
// We do not emit invalid escapes highlighting here. The lexer would likely be in a bad
// state and this token contains junks, since `'` is not a reliable delimiter (consider
// lifetimes). Nonetheless, parser errors should already be emitted.
return;
}

Expand All @@ -46,6 +49,7 @@ pub(super) fn highlight_escape_char(stack: &mut Highlights, char: &Char, start:

pub(super) fn highlight_escape_byte(stack: &mut Highlights, byte: &Byte, start: TextSize) {
if byte.value().is_none() {
// See `highlight_escape_char` for why no error highlighting here.
return;
}

Expand Down

0 comments on commit 51b35cc

Please sign in to comment.