@@ -38,11 +38,11 @@ type FourslashTest struct {
38
38
testData * TestData // !!! consolidate test files from test data and script info
39
39
baselines map [string ]* strings.Builder
40
40
rangesByText * collections.MultiMap [string , * RangeMarker ]
41
- config * ls.UserPreferences
42
41
43
42
scriptInfos map [string ]* scriptInfo
44
43
converters * ls.Converters
45
44
45
+ userPreferences * ls.UserPreferences
46
46
currentCaretPosition lsproto.Position
47
47
lastKnownMarkerName * string
48
48
activeFilename string
@@ -282,7 +282,7 @@ func sendRequest[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto.
282
282
req := lsproto.ResponseMessage {
283
283
ID : req .ID ,
284
284
JSONRPC : req .JSONRPC ,
285
- Result : []any {& f .config },
285
+ Result : []any {& f .userPreferences },
286
286
}
287
287
f .writeMsg (t , req .Message ())
288
288
resp = f .readMsg (t )
@@ -324,13 +324,21 @@ func (f *FourslashTest) readMsg(t *testing.T) *lsproto.Message {
324
324
return msg
325
325
}
326
326
327
- func (f * FourslashTest ) configure (t * testing.T , config * ls.UserPreferences ) {
328
- f .config = config
327
+ func (f * FourslashTest ) Configure (t * testing.T , config * ls.UserPreferences ) {
328
+ f .userPreferences = config
329
329
sendNotification (t , f , lsproto .WorkspaceDidChangeConfigurationInfo , & lsproto.DidChangeConfigurationParams {
330
330
Settings : config ,
331
331
})
332
332
}
333
333
334
+ func (f * FourslashTest ) ConfigureWithReset (t * testing.T , config * ls.UserPreferences ) (reset func ()) {
335
+ originalConfig := f .userPreferences .Copy ()
336
+ f .Configure (t , config )
337
+ return func () {
338
+ f .Configure (t , originalConfig )
339
+ }
340
+ }
341
+
334
342
func (f * FourslashTest ) GoToMarkerOrRange (t * testing.T , markerOrRange MarkerOrRange ) {
335
343
f .goToMarker (t , markerOrRange )
336
344
}
@@ -572,10 +580,9 @@ func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *Completi
572
580
Position : f .currentCaretPosition ,
573
581
Context : & lsproto.CompletionContext {},
574
582
}
575
- if expected == nil {
576
- f .configure (t , nil )
577
- } else {
578
- f .configure (t , expected .UserPreferences )
583
+ if expected != nil && expected .UserPreferences != nil {
584
+ reset := f .ConfigureWithReset (t , expected .UserPreferences )
585
+ defer reset ()
579
586
}
580
587
resMsg , result , resultOk := sendRequest (t , f , lsproto .TextDocumentCompletionInfo , params )
581
588
if resMsg == nil {
@@ -1408,6 +1415,12 @@ func (f *FourslashTest) getCurrentPositionPrefix() string {
1408
1415
}
1409
1416
1410
1417
func (f * FourslashTest ) BaselineAutoImportsCompletions (t * testing.T , markerNames []string ) {
1418
+ reset := f .ConfigureWithReset (t , & ls.UserPreferences {
1419
+ IncludeCompletionsForModuleExports : ptrTo (true ),
1420
+ IncludeCompletionsForImportStatements : ptrTo (true ),
1421
+ })
1422
+ defer reset ()
1423
+
1411
1424
for _ , markerName := range markerNames {
1412
1425
f .GoToMarker (t , markerName )
1413
1426
params := & lsproto.CompletionParams {
0 commit comments