@@ -378,53 +378,6 @@ https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.`
378
378
return fmt .Errorf (msg ), s .applyCriticalErrorToFiles (ctx , msg , openFiles )
379
379
}
380
380
381
- // If the user has one active go.mod file, they may still be editing files
382
- // in nested modules. Check the module of each open file and add warnings
383
- // that the nested module must be opened as a workspace folder.
384
- if len (s .workspaceModFiles ) == 1 {
385
- // Get the active root go.mod file to compare against.
386
- var rootMod string
387
- for uri := range s .workspaceModFiles {
388
- rootMod = uri .Filename ()
389
- }
390
- rootDir := filepath .Dir (rootMod )
391
- nestedModules := make (map [string ][]* Overlay )
392
- for _ , fh := range openFiles {
393
- mod , err := findRootPattern (ctx , filepath .Dir (fh .URI ().Filename ()), "go.mod" , s )
394
- if err != nil {
395
- if ctx .Err () != nil {
396
- return ctx .Err (), nil
397
- }
398
- continue
399
- }
400
- if mod == "" {
401
- continue
402
- }
403
- if mod != rootMod && source .InDir (rootDir , mod ) {
404
- modDir := filepath .Dir (mod )
405
- nestedModules [modDir ] = append (nestedModules [modDir ], fh )
406
- }
407
- }
408
- var multiModuleMsg string
409
- if s .view .goversion >= 18 {
410
- multiModuleMsg = `To work on multiple modules at once, please use a go.work file.
411
- See https://github.com/golang/tools/blob/master/gopls/doc/workspace.md for more information on using workspaces.`
412
- } else {
413
- multiModuleMsg = `To work on multiple modules at once, please upgrade to Go 1.18 and use a go.work file.
414
- See https://github.com/golang/tools/blob/master/gopls/doc/workspace.md for more information on using workspaces.`
415
- }
416
- // Add a diagnostic to each file in a nested module to mark it as
417
- // "orphaned". Don't show a general diagnostic in the progress bar,
418
- // because the user may still want to edit a file in a nested module.
419
- var srcDiags []* source.Diagnostic
420
- for modDir , files := range nestedModules {
421
- msg := fmt .Sprintf ("This file is in %s, which is a nested module in the %s module.\n %s" , modDir , rootMod , multiModuleMsg )
422
- srcDiags = append (srcDiags , s .applyCriticalErrorToFiles (ctx , msg , files )... )
423
- }
424
- if len (srcDiags ) != 0 {
425
- return fmt .Errorf ("You have opened a nested module.\n %s" , multiModuleMsg ), srcDiags
426
- }
427
- }
428
381
return nil , nil
429
382
}
430
383
0 commit comments