From 0b77995d80728a75002e3501d23bf0d1b6e142ce Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Mon, 29 Aug 2022 21:55:58 +0800 Subject: [PATCH] fix(scm): convert to Windows path with `/` instead of `\` --- src/environment/shell_unix.go | 2 +- src/environment/shell_windows.go | 2 +- src/segments/scm.go | 6 +++--- src/segments/svn.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/environment/shell_unix.go b/src/environment/shell_unix.go index d715be52..23fb4e3a 100644 --- a/src/environment/shell_unix.go +++ b/src/environment/shell_unix.go @@ -106,7 +106,7 @@ func (env *ShellEnvironment) InWSLSharedDrive() bool { } func (env *ShellEnvironment) ConvertToWindowsPath(path string) string { - windowsPath, err := env.RunCommand("wslpath", "-w", path) + windowsPath, err := env.RunCommand("wslpath", "-m", path) if err == nil { return windowsPath } diff --git a/src/environment/shell_windows.go b/src/environment/shell_windows.go index 3acf5b60..6dc746b0 100644 --- a/src/environment/shell_windows.go +++ b/src/environment/shell_windows.go @@ -228,7 +228,7 @@ func (env *ShellEnvironment) InWSLSharedDrive() bool { } func (env *ShellEnvironment) ConvertToWindowsPath(path string) string { - return path + return strings.ReplaceAll(path, `\`, "/") } func (env *ShellEnvironment) ConvertToLinuxPath(path string) string { diff --git a/src/segments/scm.go b/src/segments/scm.go index d9abef14..8bc8963d 100644 --- a/src/segments/scm.go +++ b/src/segments/scm.go @@ -94,10 +94,10 @@ func (s *scm) FileContents(folder, file string) string { } func (s *scm) convertToWindowsPath(path string) string { - if !s.IsWslSharedPath { - return path + if s.env.GOOS() == environment.WINDOWS || s.IsWslSharedPath { + return s.env.ConvertToWindowsPath(path) } - return s.env.ConvertToWindowsPath(path) + return path } func (s *scm) convertToLinuxPath(path string) string { diff --git a/src/segments/svn.go b/src/segments/svn.go index 292a1ec6..abd12fb7 100644 --- a/src/segments/svn.go +++ b/src/segments/svn.go @@ -81,7 +81,7 @@ func (s *Svn) shouldDisplay() bool { s.workingDir = Svndir.Path s.rootDir = Svndir.Path // convert the worktree file path to a windows one when in wsl 2 shared folder - s.realDir = strings.TrimSuffix(s.convertToWindowsPath(Svndir.Path), ".svn") + s.realDir = strings.TrimSuffix(s.convertToWindowsPath(Svndir.Path), "/.svn") return true } // handle worktree