@@ -8,7 +8,7 @@ import { MultilineTokens2, SparseEncodedTokens, TokensStore2 } from 'vs/editor/c
88import { Range } from 'vs/editor/common/core/range' ;
99import { TextModel } from 'vs/editor/common/model/textModel' ;
1010import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model' ;
11- import { MetadataConsts , TokenMetadata } from 'vs/editor/common/modes' ;
11+ import { MetadataConsts , TokenMetadata , FontStyle } from 'vs/editor/common/modes' ;
1212import { createTextModel } from 'vs/editor/test/common/editorTestUtils' ;
1313import { LineTokens } from 'vs/editor/common/core/lineTokens' ;
1414
@@ -387,4 +387,50 @@ suite('TokensStore', () => {
387387 const lineTokens = store . addSemanticTokens ( 36451 , new LineTokens ( new Uint32Array ( [ 60 , 1 ] ) , ` if (flags & ModifierFlags.Ambient) {` ) ) ;
388388 assert . equal ( lineTokens . getCount ( ) , 7 ) ;
389389 } ) ;
390+
391+
392+ test ( 'issue #95949: Identifiers are colored in bold when targetting keywords' , ( ) => {
393+
394+ function createTMMetadata ( foreground : number , fontStyle : number , languageId : number ) : number {
395+ return (
396+ ( languageId << MetadataConsts . LANGUAGEID_OFFSET )
397+ | ( fontStyle << MetadataConsts . FONT_STYLE_OFFSET )
398+ | ( foreground << MetadataConsts . FOREGROUND_OFFSET )
399+ ) >>> 0 ;
400+ }
401+
402+ function toArr ( lineTokens : LineTokens ) : number [ ] {
403+ let r : number [ ] = [ ] ;
404+ for ( let i = 0 ; i < lineTokens . getCount ( ) ; i ++ ) {
405+ r . push ( lineTokens . getEndOffset ( i ) ) ;
406+ r . push ( lineTokens . getMetadata ( i ) ) ;
407+ }
408+ return r ;
409+ }
410+
411+ const store = new TokensStore2 ( ) ;
412+
413+ store . set ( [
414+ new MultilineTokens2 ( 1 , new SparseEncodedTokens ( new Uint32Array ( [
415+ 0 , 6 , 11 , ( 1 << MetadataConsts . FOREGROUND_OFFSET ) | MetadataConsts . SEMANTIC_USE_FOREGROUND ,
416+ ] ) ) )
417+ ] , true ) ;
418+
419+ const lineTokens = store . addSemanticTokens ( 1 , new LineTokens ( new Uint32Array ( [
420+ 5 , createTMMetadata ( 5 , FontStyle . Bold , 53 ) ,
421+ 14 , createTMMetadata ( 1 , FontStyle . None , 53 ) ,
422+ 17 , createTMMetadata ( 6 , FontStyle . None , 53 ) ,
423+ 18 , createTMMetadata ( 1 , FontStyle . None , 53 ) ,
424+ ] ) , `const hello = 123;` ) ) ;
425+
426+ const actual = toArr ( lineTokens ) ;
427+ assert . deepEqual ( actual , [
428+ 5 , createTMMetadata ( 5 , FontStyle . Bold , 53 ) ,
429+ 6 , createTMMetadata ( 1 , FontStyle . None , 53 ) ,
430+ 11 , createTMMetadata ( 1 , FontStyle . None , 53 ) ,
431+ 14 , createTMMetadata ( 1 , FontStyle . None , 53 ) ,
432+ 17 , createTMMetadata ( 6 , FontStyle . None , 53 ) ,
433+ 18 , createTMMetadata ( 1 , FontStyle . None , 53 )
434+ ] ) ;
435+ } ) ;
390436} ) ;
0 commit comments