Skip to content

Commit bbe31db

Browse files
fix dependency provider not found and no workspace folder configured issue
Signed-off-by: Savitha Raghunathan <[email protected]>
1 parent 8c000cb commit bbe31db

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lsp/base_service_client/base_service_client.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ func NewLSPServiceClientBase(
183183
initializeParams.RootURI = "file://" + initializeParams.RootURI
184184
}
185185

186+
// Populate WorkspaceFolders from initialize params
187+
if len(initializeParams.WorkspaceFolders) > 0 {
188+
for _, folder := range initializeParams.WorkspaceFolders {
189+
sc.BaseConfig.WorkspaceFolders = append(sc.BaseConfig.WorkspaceFolders, folder.URI)
190+
}
191+
} else if initializeParams.RootURI != "" {
192+
sc.BaseConfig.WorkspaceFolders = append(sc.BaseConfig.WorkspaceFolders, initializeParams.RootURI)
193+
}
194+
186195
if initializeParams.ProcessID == 0 {
187196
initializeParams.ProcessID = int32(os.Getpid())
188197
}
@@ -281,9 +290,18 @@ func (sc *LSPServiceClientBase) GetDependencies(ctx context.Context) (map[uri.UR
281290
if cmdStr == "" {
282291
return nil, fmt.Errorf("dependency provider path not set")
283292
}
293+
if len(sc.BaseConfig.WorkspaceFolders) == 0 {
294+
return nil, fmt.Errorf("no workspace folders configured")
295+
}
284296
// Expects dependency provider to output provider.Dep structs to stdout
285297
cmd := exec.Command(cmdStr)
286-
cmd.Dir = sc.BaseConfig.WorkspaceFolders[0][7:]
298+
workspaceURI := sc.BaseConfig.WorkspaceFolders[0]
299+
// Remove file:// prefix if present
300+
if strings.HasPrefix(workspaceURI, "file://") {
301+
cmd.Dir = workspaceURI[7:]
302+
} else {
303+
cmd.Dir = workspaceURI
304+
}
287305
dataR, err := cmd.Output()
288306
if err != nil {
289307
return nil, err

0 commit comments

Comments
 (0)