diff --git a/src/segments/path.go b/src/segments/path.go index fb038b41..2b14808c 100644 --- a/src/segments/path.go +++ b/src/segments/path.go @@ -127,6 +127,9 @@ func (pt *Path) Init(props properties.Properties, env environment.Environment) { func (pt *Path) setStyle() { if len(pt.relative) == 0 { pt.Path = pt.root + if strings.HasSuffix(pt.Path, ":") { + pt.Path += pt.env.PathSeparator() + } return } switch style := pt.props.GetString(properties.Style, Agnoster); style { diff --git a/src/segments/path_test.go b/src/segments/path_test.go index f2cdd122..420f3e94 100644 --- a/src/segments/path_test.go +++ b/src/segments/path_test.go @@ -294,7 +294,7 @@ func TestAgnosterPathStyles(t *testing.T) { }, { Style: Letter, - Expected: "C:", + Expected: "C:\\", HomePath: homeDirWindows, Pwd: "C:\\", GOOS: environment.WINDOWS, @@ -563,7 +563,7 @@ func TestAgnosterPathStyles(t *testing.T) { }, { Style: AgnosterShort, - Expected: "C:", + Expected: "C:/", HomePath: homeDir, Pwd: "/mnt/c", Pswd: "C:", @@ -594,7 +594,7 @@ func TestAgnosterPathStyles(t *testing.T) { }, { Style: AgnosterShort, - Expected: "C:", + Expected: "C:\\", HomePath: homeDirWindows, Pwd: "C:", GOOS: environment.WINDOWS, @@ -743,7 +743,7 @@ func TestFullAndFolderPath(t *testing.T) { {Style: Folder, FolderSeparatorIcon: "|", Pwd: "/a/b/c/d", Expected: "d"}, // for Windows paths - {Style: Folder, FolderSeparatorIcon: "\\", Pwd: "C:\\", Expected: "C:", PathSeparator: "\\", GOOS: environment.WINDOWS}, + {Style: Folder, FolderSeparatorIcon: "\\", Pwd: "C:\\", Expected: "C:\\", PathSeparator: "\\", GOOS: environment.WINDOWS}, {Style: Folder, FolderSeparatorIcon: "\\", Pwd: homeDirWindows, Expected: "~", PathSeparator: "\\", GOOS: environment.WINDOWS}, {Style: Full, FolderSeparatorIcon: "\\", Pwd: homeDirWindows, Expected: "~", PathSeparator: "\\", GOOS: environment.WINDOWS}, {Style: Full, FolderSeparatorIcon: "\\", Pwd: homeDirWindows + "\\abc", Expected: "~\\abc", PathSeparator: "\\", GOOS: environment.WINDOWS},