Render literal escaping errors in hovers

This commit is contained in:
Lukas Wirth 2024-05-13 12:51:57 +02:00
parent 253929f6ae
commit a39c0493a1
10 changed files with 71 additions and 82 deletions

View file

@ -25,7 +25,7 @@ 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() {
if char.value().is_err() {
// 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.
@ -48,7 +48,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() {
if byte.value().is_err() {
// See `highlight_escape_char` for why no error highlighting here.
return;
}

View file

@ -30,7 +30,7 @@ pub(super) fn ra_fixture(
if !active_parameter.ident().map_or(false, |name| name.text().starts_with("ra_fixture")) {
return None;
}
let value = literal.value()?;
let value = literal.value().ok()?;
if let Some(range) = literal.open_quote_text_range() {
hl.add(HlRange { range, highlight: HlTag::StringLiteral.into(), binding_hash: None })