From a15dda48c696cb14d490ee91f40949d5cd538aba Mon Sep 17 00:00:00 2001 From: Roland Ruckerbauer Date: Sun, 15 Nov 2020 17:43:14 +0100 Subject: format string highlighting: handle hex + debug type specifier --- crates/syntax/src/ast/token_ext.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/syntax') diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs index 2661c753e..ac0326420 100644 --- a/crates/syntax/src/ast/token_ext.rs +++ b/crates/syntax/src/ast/token_ext.rs @@ -331,10 +331,22 @@ pub trait HasFormatSpecifier: AstToken { } c if c == '_' || c.is_alphabetic() => { read_identifier(&mut chars, &mut callback); + + if chars.peek().and_then(|next| next.1.as_ref().ok()).copied() + == Some('?') + { + skip_char_and_emit( + &mut chars, + FormatSpecifier::QuestionMark, + &mut callback, + ); + } + // can be either width (indicated by dollar sign, or type in which case // the next sign has to be `}`) let next = chars.peek().and_then(|next| next.1.as_ref().ok()).copied(); + match next { Some('$') => skip_char_and_emit( &mut chars, @@ -417,6 +429,16 @@ pub trait HasFormatSpecifier: AstToken { } c if c == '_' || c.is_alphabetic() => { read_identifier(&mut chars, &mut callback); + + if chars.peek().and_then(|next| next.1.as_ref().ok()).copied() + == Some('?') + { + skip_char_and_emit( + &mut chars, + FormatSpecifier::QuestionMark, + &mut callback, + ); + } } _ => {} } -- cgit v1.2.3