@@ -11,10 +11,7 @@ import ignore from "ignore";
11
11
* @typedef {{
12
12
* defaultDialect?: string;
13
13
* schemaFilePatterns: string[];
14
- * tabSize: number;
15
- * insertSpaces: boolean;
16
14
* detectIndentation: boolean;
17
- * endOfLine: string;
18
15
* }} DocumentSettings
19
16
*/
20
17
@@ -24,6 +21,15 @@ import ignore from "ignore";
24
21
* }} Settings
25
22
*/
26
23
24
+ /**
25
+ * @typedef {{
26
+ * tabSize?: number;
27
+ * insertSpaces?: boolean;
28
+ * detectIndentation?: boolean;
29
+ * endOfLine?: string;
30
+ * }} IndentationSettings
31
+ */
32
+
27
33
export class Configuration {
28
34
#server;
29
35
@@ -68,7 +74,15 @@ export class Configuration {
68
74
this . #didChangeConfigurationHandlers = [ ] ;
69
75
70
76
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 ) ;
72
86
this . #matcher = undefined ;
73
87
74
88
for ( const handler of this . #didChangeConfigurationHandlers) {
@@ -77,20 +91,20 @@ export class Configuration {
77
91
} ) ;
78
92
}
79
93
80
- /** @type (documentUri?: string ) => Promise<DocumentSettings> */
81
- async get ( documentUri ) {
94
+ /** @type () => Promise<DocumentSettings> */
95
+ async get ( ) {
82
96
if ( ! this . #settings) {
83
97
/** @type {unknown[] } */
84
98
const config = await this . #server. workspace . getConfiguration ( [
85
99
{ section : "jsonSchemaLanguageServer" } ,
86
- { section : "editor" , scopeUri : documentUri } ,
100
+ { section : "editor" } ,
87
101
{ section : "files.eol" }
88
102
] ) ;
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 */
91
105
const indentationSettings = {
92
- tabSize : editorSettings ?. tabSize ?? this . #defaultSettings . tabSize ,
93
- insertSpaces : editorSettings ?. insertSpaces ?? this . #defaultSettings . insertSpaces ,
106
+ tabSize : editorSettings ?. tabSize ,
107
+ insertSpaces : editorSettings ?. insertSpaces ,
94
108
detectIndentation : editorSettings ?. detectIndentation ?? this . #defaultSettings. detectIndentation ,
95
109
endOfLine : eol
96
110
} ;
0 commit comments