@@ -11,10 +11,7 @@ import ignore from "ignore";
1111 * @typedef {{
1212 * defaultDialect?: string;
1313 * schemaFilePatterns: string[];
14- * tabSize: number;
15- * insertSpaces: boolean;
1614 * detectIndentation: boolean;
17- * endOfLine: string;
1815 * }} DocumentSettings
1916 */
2017
@@ -24,6 +21,15 @@ import ignore from "ignore";
2421 * }} Settings
2522 */
2623
24+ /**
25+ * @typedef {{
26+ * tabSize?: number;
27+ * insertSpaces?: boolean;
28+ * detectIndentation?: boolean;
29+ * endOfLine?: string;
30+ * }} IndentationSettings
31+ */
32+
2733export class Configuration {
2834 #server;
2935
@@ -68,7 +74,15 @@ export class Configuration {
6874 this . #didChangeConfigurationHandlers = [ ] ;
6975
7076 this . #server. onDidChangeConfiguration ( ( params ) => {
71- this . #settings = undefined ;
77+ /** @type unknown */
78+ const settings = params . settings ;
79+
80+ /** @type unknown */
81+ const fullSettings = {
82+ ...this . #defaultSettings,
83+ .../** @type Settings */ ( settings ) . jsonSchemaLanguageServer
84+ } ;
85+ this . #settings = /** @type DocumentSettings */ ( fullSettings ) ;
7286 this . #matcher = undefined ;
7387
7488 for ( const handler of this . #didChangeConfigurationHandlers) {
@@ -77,20 +91,20 @@ export class Configuration {
7791 } ) ;
7892 }
7993
80- /** @type (documentUri?: string ) => Promise<DocumentSettings> */
81- async get ( documentUri ) {
94+ /** @type () => Promise<DocumentSettings> */
95+ async get ( ) {
8296 if ( ! this . #settings) {
8397 /** @type {unknown[] } */
8498 const config = await this . #server. workspace . getConfiguration ( [
8599 { section : "jsonSchemaLanguageServer" } ,
86- { section : "editor" , scopeUri : documentUri } ,
100+ { section : "editor" } ,
87101 { section : "files.eol" }
88102 ] ) ;
89- const [ extensionSettings , editorSettings , eol ] = /** @type [{ defaultDialect?: string; schemaFilePatterns?: string[] },{ tabSize?: number; insertSpaces?: boolean; detectIndentation?: boolean } , string ] */ ( config ) ;
90- /** @type { { tabSize?: number; insertSpaces?: boolean; detectIndentation?: boolean, endOfLine?: string } } */
103+ const [ extensionSettings , editorSettings , eol ] = /** @type [DocumentSettings, IndentationSettings , string] */ ( config ) ;
104+ /** @type IndentationSettings */
91105 const indentationSettings = {
92- tabSize : editorSettings ?. tabSize ?? this . #defaultSettings . tabSize ,
93- insertSpaces : editorSettings ?. insertSpaces ?? this . #defaultSettings . insertSpaces ,
106+ tabSize : editorSettings ?. tabSize ,
107+ insertSpaces : editorSettings ?. insertSpaces ,
94108 detectIndentation : editorSettings ?. detectIndentation ?? this . #defaultSettings. detectIndentation ,
95109 endOfLine : eol
96110 } ;
0 commit comments