Skip to content

Commit

Permalink
bugfix: aztfmigrate failed to parse working directory on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Oct 11, 2024
1 parent c44e76a commit e1a9700
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/langserver/handlers/command/aztfmigrate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"

context2 "github.com/Azure/azapi-lsp/internal/context"
Expand Down Expand Up @@ -66,6 +67,12 @@ func (c AztfMigrateCommand) Handle(ctx context.Context, arguments []json.RawMess

// creating temp workspace
workingDirectory := path.Dir(strings.TrimPrefix(string(params.TextDocument.URI), "file://"))
if runtime.GOOS == "windows" {
workingDirectory = strings.ReplaceAll(workingDirectory, "%3A", ":")
workingDirectory = strings.ReplaceAll(workingDirectory, "/", "\\")
workingDirectory = strings.TrimPrefix(workingDirectory, "\\")
}
log.Printf("[INFO] working directory: %s", workingDirectory)
tempDir := filepath.Join(workingDirectory, tempFolderName)
if err := os.MkdirAll(tempDir, 0750); err != nil {
return nil, fmt.Errorf("creating temp workspace %q: %+v", tempDir, err)
Expand Down

0 comments on commit e1a9700

Please sign in to comment.