@@ -249,6 +249,13 @@ export interface CssConfig {
249249 hover ?: any ;
250250}
251251
252+ /**
253+ * The config as the vscode-html-languageservice understands it
254+ */
255+ export interface HTMLConfig {
256+ customData ?: string [ ] ;
257+ }
258+
252259type DeepPartial < T > = T extends CompilerWarningsSettings
253260 ? T
254261 : {
@@ -273,6 +280,7 @@ export class LSConfigManager {
273280 private cssConfig : CssConfig | undefined ;
274281 private scssConfig : CssConfig | undefined ;
275282 private lessConfig : CssConfig | undefined ;
283+ private htmlConfig : HTMLConfig | undefined ;
276284 private isTrusted = true ;
277285
278286 constructor ( ) {
@@ -296,7 +304,7 @@ export class LSConfigManager {
296304 // TODO remove once we remove old transformation
297305 this . config . svelte . useNewTransformation = true ;
298306
299- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
307+ this . notifyListeners ( ) ;
300308 }
301309
302310 /**
@@ -331,7 +339,7 @@ export class LSConfigManager {
331339
332340 updateEmmetConfig ( config : VSCodeEmmetConfig ) : void {
333341 this . emmetConfig = config || { } ;
334- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
342+ this . notifyListeners ( ) ;
335343 }
336344
337345 getEmmetConfig ( ) : VSCodeEmmetConfig {
@@ -340,7 +348,7 @@ export class LSConfigManager {
340348
341349 updatePrettierConfig ( config : any ) : void {
342350 this . prettierConfig = config || { } ;
343- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
351+ this . notifyListeners ( ) ;
344352 }
345353
346354 getPrettierConfig ( ) : any {
@@ -376,7 +384,7 @@ export class LSConfigManager {
376384 this . _updateTsUserPreferences ( lang , config [ lang ] ) ;
377385 }
378386 } ) ;
379- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
387+ this . notifyListeners ( ) ;
380388 this . resolvedAutoImportExcludeCache . clear ( ) ;
381389 }
382390
@@ -390,7 +398,7 @@ export class LSConfigManager {
390398
391399 updateIsTrusted ( isTrusted : boolean ) : void {
392400 this . isTrusted = isTrusted ;
393- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
401+ this . notifyListeners ( ) ;
394402 }
395403
396404 private _updateTsUserPreferences ( lang : TsUserConfigLang , config : TSUserConfig ) {
@@ -457,7 +465,7 @@ export class LSConfigManager {
457465
458466 updateCssConfig ( config : CssConfig | undefined ) : void {
459467 this . cssConfig = config ;
460- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
468+ this . notifyListeners ( ) ;
461469 }
462470
463471 getCssConfig ( ) : CssConfig | undefined {
@@ -466,7 +474,7 @@ export class LSConfigManager {
466474
467475 updateScssConfig ( config : CssConfig | undefined ) : void {
468476 this . scssConfig = config ;
469- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
477+ this . notifyListeners ( ) ;
470478 }
471479
472480 getScssConfig ( ) : CssConfig | undefined {
@@ -475,20 +483,29 @@ export class LSConfigManager {
475483
476484 updateLessConfig ( config : CssConfig | undefined ) : void {
477485 this . lessConfig = config ;
478- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
486+ this . notifyListeners ( ) ;
479487 }
480488
481489 getLessConfig ( ) : CssConfig | undefined {
482490 return this . lessConfig ;
483491 }
484492
493+ updateHTMLConfig ( config : HTMLConfig | undefined ) : void {
494+ this . htmlConfig = config ;
495+ this . notifyListeners ( ) ;
496+ }
497+
498+ getHTMLConfig ( ) : HTMLConfig | undefined {
499+ return this . htmlConfig ;
500+ }
501+
485502 updateTsJsFormateConfig ( config : Record < TsUserConfigLang , TSUserConfig > ) : void {
486503 ( [ 'typescript' , 'javascript' ] as const ) . forEach ( ( lang ) => {
487504 if ( config [ lang ] ) {
488505 this . _updateTsFormatConfig ( lang , config [ lang ] ) ;
489506 }
490507 } ) ;
491- this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
508+ this . notifyListeners ( ) ;
492509 }
493510
494511 private getDefaultFormatCodeOptions ( ) : ts . FormatCodeSettings {
@@ -568,4 +585,15 @@ export class LSConfigManager {
568585 : ts . SemicolonPreference . Remove
569586 } ;
570587 }
588+
589+ private scheduledUpdate : NodeJS . Timeout | undefined ;
590+ private notifyListeners ( ) {
591+ if ( this . scheduledUpdate ) {
592+ clearTimeout ( this . scheduledUpdate ) ;
593+ }
594+ this . scheduledUpdate = setTimeout ( ( ) => {
595+ this . scheduledUpdate = undefined ;
596+ this . listeners . forEach ( ( listener ) => listener ( this ) ) ;
597+ } ) ;
598+ }
571599}
0 commit comments