Fix highlighting of byte escape sequences

Currently non-UTF8 escape sequences in byte strings and any escape
sequences in byte literals are ignored.
This commit is contained in:
oxalica 2023-07-17 22:28:57 +08:00
parent 37f84c101b
commit de1f766820
No known key found for this signature in database
GPG key ID: D425CB23CADE82D9
5 changed files with 48 additions and 10 deletions

View file

@ -24,7 +24,7 @@ use syntax::{
use crate::{
syntax_highlighting::{
escape::{highlight_escape_char, highlight_escape_string},
escape::{highlight_escape_byte, highlight_escape_char, highlight_escape_string},
format::highlight_format_string,
highlights::Highlights,
macro_::MacroHighlighter,
@ -471,6 +471,14 @@ fn traverse(
};
highlight_escape_char(hl, &char, range.start())
} else if ast::Byte::can_cast(token.kind())
&& ast::Byte::can_cast(descended_token.kind())
{
let Some(byte) = ast::Byte::cast(token) else {
continue;
};
highlight_escape_byte(hl, &byte, range.start())
}
}