Skip to content

Commit

Permalink
Use directory ilsp helper
Browse files Browse the repository at this point in the history
  • Loading branch information
appilon committed Dec 8, 2020
1 parent a606157 commit f014bc3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/langserver/handlers/command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import (
)

func TerraformInitHandler(ctx context.Context, args cmd.CommandArgs) (interface{}, error) {
fileUri, ok := args.GetString("uri")
if !ok || fileUri == "" {
return nil, fmt.Errorf("%w: expected uri argument to be set", code.InvalidParams.Err())
dirUri, ok := args.GetString("uri")
if !ok || dirUri == "" {
return nil, fmt.Errorf("%w: expected dir uri argument to be set", code.InvalidParams.Err())
}

fh := ilsp.FileHandlerFromDocumentURI(lsp.DocumentURI(fileUri))
dh := ilsp.FileHandlerFromDirURI(lsp.DocumentURI(dirUri))

cf, err := lsctx.RootModuleFinder(ctx)
if err != nil {
return nil, err
}

rm, err := cf.RootModuleByPath(fh.Dir())
rm, err := cf.RootModuleByPath(dh.Dir())
if err != nil {
return nil, err
}
Expand All @@ -49,7 +49,7 @@ func TerraformInitHandler(ctx context.Context, args cmd.CommandArgs) (interface{
}
err = w.AddPaths(paths)
if err != nil {
return nil, fmt.Errorf("failed to add watch for dir (%s): %+v", fh.Dir(), err)
return nil, fmt.Errorf("failed to add watch for dir (%s): %+v", dh.Dir(), err)
}

return nil, nil
Expand Down

0 comments on commit f014bc3

Please sign in to comment.