@@ -33,13 +33,16 @@ import type {
33
33
InitializeParams ,
34
34
ServerCapabilities
35
35
} from "vscode-languageserver" ;
36
+ import type { EditorSettings , FilesSettings , LanguageServerSettings } from "../services/configuration.js" ;
36
37
37
38
38
- export class TestClient < Configuration > {
39
+ export class TestClient {
39
40
private client : Connection ;
40
41
private serverName : string ;
41
42
private _serverCapabilities : ServerCapabilities | undefined ;
42
- private _settings : Partial < Configuration > | undefined ;
43
+ private languageServerSettings : Partial < LanguageServerSettings > | undefined ;
44
+ private editorSettings : Partial < EditorSettings > | undefined ;
45
+ private filesSettings : Partial < FilesSettings > | undefined ;
43
46
private configurationChangeNotificationOptions : DidChangeConfigurationRegistrationOptions | null | undefined ;
44
47
private openDocuments : Set < string > ;
45
48
private workspaceFolder : Promise < string > ;
@@ -102,11 +105,18 @@ export class TestClient<Configuration> {
102
105
} ) ;
103
106
104
107
this . client . onRequest ( ConfigurationRequest . type , ( params ) => {
105
- return params . items
106
- . filter ( ( configurationItem ) => configurationItem . section === this . serverName )
107
- . map ( ( ) => {
108
- return this . _settings ;
109
- } ) ;
108
+ return params . items . map ( ( configurationItem ) => {
109
+ switch ( configurationItem . section ) {
110
+ case this . serverName :
111
+ return this . languageServerSettings ;
112
+ case "editor" :
113
+ return this . editorSettings ;
114
+ case "files" :
115
+ return this . filesSettings ;
116
+ default :
117
+ throw Error ( `Unsupported configuration section: ${ configurationItem . section } ` ) ;
118
+ }
119
+ } ) ;
110
120
} ) ;
111
121
112
122
this . client . listen ( ) ;
@@ -116,10 +126,6 @@ export class TestClient<Configuration> {
116
126
return structuredClone ( this . _serverCapabilities ) ;
117
127
}
118
128
119
- get settings ( ) {
120
- return structuredClone ( this . _settings ) ;
121
- }
122
-
123
129
async start ( params : Partial < InitializeParams > = { } ) {
124
130
const defaultInitParams : InitializeParams = {
125
131
processId : null ,
@@ -208,7 +214,7 @@ export class TestClient<Configuration> {
208
214
// Wait for dynamic registrations to be completed
209
215
await wait ( 100 ) ;
210
216
211
- await this . changeConfiguration ( this . _settings ?? { } ) ;
217
+ await this . changeConfiguration ( ) ;
212
218
}
213
219
214
220
async stop ( ) {
@@ -218,8 +224,10 @@ export class TestClient<Configuration> {
218
224
this . client . dispose ( ) ;
219
225
}
220
226
221
- async changeConfiguration ( settings : Partial < Configuration > ) {
222
- this . _settings = settings ;
227
+ async changeConfiguration ( languageServerSettings ?: Partial < LanguageServerSettings > , editorSettings ?: Partial < EditorSettings > , filesSettings ?: Partial < FilesSettings > ) {
228
+ this . languageServerSettings = languageServerSettings ?? this . languageServerSettings ;
229
+ this . editorSettings = editorSettings ?? this . editorSettings ;
230
+ this . filesSettings = filesSettings ?? this . filesSettings ;
223
231
224
232
const buildCompleted = this . buildCompleted ( ) ;
225
233
@@ -230,7 +238,9 @@ export class TestClient<Configuration> {
230
238
} else if ( this . configurationChangeNotificationOptions ) {
231
239
await this . client . sendNotification ( DidChangeConfigurationNotification . type , {
232
240
settings : {
233
- [ this . serverName ] : this . _settings
241
+ [ this . serverName ] : this . languageServerSettings ,
242
+ editor : this . editorSettings ,
243
+ files : this . filesSettings
234
244
}
235
245
} ) ;
236
246
}
0 commit comments