@@ -3312,9 +3312,9 @@ export interface IUnicodeHighlightOptions {
3312
3312
ambiguousCharacters ?: boolean ;
3313
3313
includeComments ?: boolean | InUntrustedWorkspace ;
3314
3314
/**
3315
- * A list of allowed code points in a single string .
3315
+ * A map of allowed characters (true: allowed) .
3316
3316
*/
3317
- allowedCharacters ?: string ;
3317
+ allowedCharacters ?: Record < string , true > ;
3318
3318
}
3319
3319
3320
3320
/**
@@ -3340,7 +3340,7 @@ class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting
3340
3340
invisibleCharacters : true ,
3341
3341
ambiguousCharacters : true ,
3342
3342
includeComments : inUntrustedWorkspace ,
3343
- allowedCharacters : '' ,
3343
+ allowedCharacters : { } ,
3344
3344
} ;
3345
3345
3346
3346
super (
@@ -3374,14 +3374,34 @@ class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting
3374
3374
} ,
3375
3375
[ unicodeHighlightConfigKeys . allowedCharacters ] : {
3376
3376
restricted : true ,
3377
- type : 'string ' ,
3377
+ type : 'object ' ,
3378
3378
default : defaults . allowedCharacters ,
3379
- description : nls . localize ( 'unicodeHighlight.allowedCharacters' , "Defines allowed characters that are not being highlighted." )
3379
+ description : nls . localize ( 'unicodeHighlight.allowedCharacters' , "Defines allowed characters that are not being highlighted." ) ,
3380
+ additionalProperties : {
3381
+ type : 'boolean'
3382
+ }
3380
3383
} ,
3381
3384
}
3382
3385
) ;
3383
3386
}
3384
3387
3388
+ public override applyUpdate ( value : Required < Readonly < IUnicodeHighlightOptions > > , update : Required < Readonly < IUnicodeHighlightOptions > > ) : ApplyUpdateResult < Required < Readonly < IUnicodeHighlightOptions > > > {
3389
+ let didChange = false ;
3390
+ if ( update . allowedCharacters ) {
3391
+ // Treat allowedCharacters atomically
3392
+ if ( ! objects . equals ( value . allowedCharacters , update . allowedCharacters ) ) {
3393
+ value = { ...value , allowedCharacters : update . allowedCharacters } ;
3394
+ didChange = true ;
3395
+ }
3396
+ }
3397
+
3398
+ const result = super . applyUpdate ( value , update ) ;
3399
+ if ( didChange ) {
3400
+ return new ApplyUpdateResult ( result . newValue , true ) ;
3401
+ }
3402
+ return result ;
3403
+ }
3404
+
3385
3405
public validate ( _input : any ) : InternalUnicodeHighlightOptions {
3386
3406
if ( ! _input || typeof _input !== 'object' ) {
3387
3407
return this . defaultValue ;
@@ -3392,16 +3412,22 @@ class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting
3392
3412
invisibleCharacters : boolean ( input . invisibleCharacters , this . defaultValue . invisibleCharacters ) ,
3393
3413
ambiguousCharacters : boolean ( input . ambiguousCharacters , this . defaultValue . ambiguousCharacters ) ,
3394
3414
includeComments : primitiveSet < boolean | InUntrustedWorkspace > ( input . includeComments , inUntrustedWorkspace , [ true , false , inUntrustedWorkspace ] ) ,
3395
- allowedCharacters : string ( input . allowedCharacters , '' ) ,
3415
+ allowedCharacters : this . validateAllowedCharacters ( _input . allowedCharacters , this . defaultValue . allowedCharacters ) ,
3396
3416
} ;
3397
3417
}
3398
- }
3399
3418
3400
- function string ( value : unknown , defaultValue : string ) : string {
3401
- if ( typeof value !== 'string' ) {
3402
- return defaultValue ;
3419
+ private validateAllowedCharacters ( map : unknown , defaultValue : Record < string , true > ) : Record < string , true > {
3420
+ if ( ( typeof map !== 'object' ) || ! map ) {
3421
+ return defaultValue ;
3422
+ }
3423
+ const result : Record < string , true > = { } ;
3424
+ for ( const [ key , value ] of Object . entries ( map ) ) {
3425
+ if ( value === true ) {
3426
+ result [ key ] = true ;
3427
+ }
3428
+ }
3429
+ return result ;
3403
3430
}
3404
- return value ;
3405
3431
}
3406
3432
3407
3433
//#endregion
0 commit comments