@@ -3312,9 +3312,9 @@ export interface IUnicodeHighlightOptions {
33123312 ambiguousCharacters ?: boolean ;
33133313 includeComments ?: boolean | InUntrustedWorkspace ;
33143314 /**
3315- * A list of allowed code points in a single string .
3315+ * A map of allowed characters (true: allowed) .
33163316 */
3317- allowedCharacters ?: string ;
3317+ allowedCharacters ?: Record < string , true > ;
33183318}
33193319
33203320/**
@@ -3340,7 +3340,7 @@ class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting
33403340 invisibleCharacters : true ,
33413341 ambiguousCharacters : true ,
33423342 includeComments : inUntrustedWorkspace ,
3343- allowedCharacters : '' ,
3343+ allowedCharacters : { } ,
33443344 } ;
33453345
33463346 super (
@@ -3374,14 +3374,34 @@ class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting
33743374 } ,
33753375 [ unicodeHighlightConfigKeys . allowedCharacters ] : {
33763376 restricted : true ,
3377- type : 'string ' ,
3377+ type : 'object ' ,
33783378 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+ }
33803383 } ,
33813384 }
33823385 ) ;
33833386 }
33843387
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+
33853405 public validate ( _input : any ) : InternalUnicodeHighlightOptions {
33863406 if ( ! _input || typeof _input !== 'object' ) {
33873407 return this . defaultValue ;
@@ -3392,16 +3412,22 @@ class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting
33923412 invisibleCharacters : boolean ( input . invisibleCharacters , this . defaultValue . invisibleCharacters ) ,
33933413 ambiguousCharacters : boolean ( input . ambiguousCharacters , this . defaultValue . ambiguousCharacters ) ,
33943414 includeComments : primitiveSet < boolean | InUntrustedWorkspace > ( input . includeComments , inUntrustedWorkspace , [ true , false , inUntrustedWorkspace ] ) ,
3395- allowedCharacters : string ( input . allowedCharacters , '' ) ,
3415+ allowedCharacters : this . validateAllowedCharacters ( _input . allowedCharacters , this . defaultValue . allowedCharacters ) ,
33963416 } ;
33973417 }
3398- }
33993418
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 ;
34033430 }
3404- return value ;
34053431}
34063432
34073433//#endregion
0 commit comments