From 3d0d8f9a79090e44748496f0e81b74254db30b67 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Thu, 30 May 2024 21:26:38 +0200 Subject: [PATCH] Fix root module discovery --- internal/features/rootmodules/events.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/features/rootmodules/events.go b/internal/features/rootmodules/events.go index 235d8b2a6..79ed64d36 100644 --- a/internal/features/rootmodules/events.go +++ b/internal/features/rootmodules/events.go @@ -14,13 +14,15 @@ import ( "github.com/hashicorp/terraform-ls/internal/terraform/datadir" "github.com/hashicorp/terraform-ls/internal/terraform/exec" op "github.com/hashicorp/terraform-ls/internal/terraform/module/operation" + "github.com/hashicorp/terraform-ls/internal/uri" ) func (f *RootModulesFeature) discover(path string, files []string) error { - if uri, ok := datadir.ModuleUriFromDataDir(path); ok { + rawUri := uri.FromPath(path) + if uri, ok := datadir.ModuleUriFromDataDir(rawUri); ok { f.logger.Printf("discovered root module in %s", uri) - - err := f.Store.AddIfNotExists(uri) + dir := document.DirHandleFromURI(uri) + err := f.Store.AddIfNotExists(dir.Path()) if err != nil { return err }