@@ -245,28 +245,29 @@ pub(crate) fn highlight(
245
245
stack. push ( ) ;
246
246
if is_format_string {
247
247
string. lex_format_specifier ( |piece_range, kind| {
248
- let highlight = match kind {
249
- FormatSpecifier :: Open
250
- | FormatSpecifier :: Close
251
- | FormatSpecifier :: Colon
252
- | FormatSpecifier :: Fill
253
- | FormatSpecifier :: Align
254
- | FormatSpecifier :: Sign
255
- | FormatSpecifier :: NumberSign
256
- | FormatSpecifier :: DollarSign
257
- | FormatSpecifier :: Dot
258
- | FormatSpecifier :: Asterisk
259
- | FormatSpecifier :: QuestionMark => HighlightTag :: Attribute ,
260
- FormatSpecifier :: Integer | FormatSpecifier :: Zero => {
261
- HighlightTag :: NumericLiteral
262
- }
263
- FormatSpecifier :: Identifier => HighlightTag :: Local ,
264
- } ;
265
- stack. add ( HighlightedRange {
266
- range : piece_range + range. start ( ) ,
267
- highlight : highlight. into ( ) ,
268
- binding_hash : None ,
269
- } ) ;
248
+ if let Some ( highlight) = highlight_format_specifier ( kind) {
249
+ stack. add ( HighlightedRange {
250
+ range : piece_range + range. start ( ) ,
251
+ highlight : highlight. into ( ) ,
252
+ binding_hash : None ,
253
+ } ) ;
254
+ }
255
+ } ) ;
256
+ }
257
+ stack. pop ( ) ;
258
+ } else if let Some ( string) =
259
+ element_to_highlight. as_token ( ) . cloned ( ) . and_then ( ast:: RawString :: cast)
260
+ {
261
+ stack. push ( ) ;
262
+ if is_format_string {
263
+ string. lex_format_specifier ( |piece_range, kind| {
264
+ if let Some ( highlight) = highlight_format_specifier ( kind) {
265
+ stack. add ( HighlightedRange {
266
+ range : piece_range + range. start ( ) ,
267
+ highlight : highlight. into ( ) ,
268
+ binding_hash : None ,
269
+ } ) ;
270
+ }
270
271
} ) ;
271
272
}
272
273
stack. pop ( ) ;
@@ -277,6 +278,24 @@ pub(crate) fn highlight(
277
278
stack. flattened ( )
278
279
}
279
280
281
+ fn highlight_format_specifier ( kind : FormatSpecifier ) -> Option < HighlightTag > {
282
+ Some ( match kind {
283
+ FormatSpecifier :: Open
284
+ | FormatSpecifier :: Close
285
+ | FormatSpecifier :: Colon
286
+ | FormatSpecifier :: Fill
287
+ | FormatSpecifier :: Align
288
+ | FormatSpecifier :: Sign
289
+ | FormatSpecifier :: NumberSign
290
+ | FormatSpecifier :: DollarSign
291
+ | FormatSpecifier :: Dot
292
+ | FormatSpecifier :: Asterisk
293
+ | FormatSpecifier :: QuestionMark => HighlightTag :: Attribute ,
294
+ FormatSpecifier :: Integer | FormatSpecifier :: Zero => HighlightTag :: NumericLiteral ,
295
+ FormatSpecifier :: Identifier => HighlightTag :: Local ,
296
+ } )
297
+ }
298
+
280
299
fn macro_call_range ( macro_call : & ast:: MacroCall ) -> Option < TextRange > {
281
300
let path = macro_call. path ( ) ?;
282
301
let name_ref = path. segment ( ) ?. name_ref ( ) ?;
0 commit comments