fix(path): correct root on full style

resolves #2939
This commit is contained in:
Jan De Dobbeleer 2022-10-14 07:45:54 +02:00 committed by Jan De Dobbeleer
parent b95aec7ffa
commit 6bc0f888c2
2 changed files with 4 additions and 2 deletions

View file

@ -364,8 +364,9 @@ func (pt *Path) getAgnosterShortPath() string {
func (pt *Path) getFullPath() string {
rel := pt.relative
if pt.root != pt.env.PathSeparator() {
rel = pt.env.PathSeparator() + rel
pathSeparator := pt.env.PathSeparator()
if pt.root != pathSeparator && !strings.HasSuffix(pt.root, pathSeparator) {
rel = pathSeparator + rel
}
path := pt.replaceFolderSeparators(rel)
return pt.root + path

View file

@ -747,6 +747,7 @@ func TestFullAndFolderPath(t *testing.T) {
{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},
{Style: Full, FolderSeparatorIcon: "\\", Pwd: "C:\\Users\\posh", Expected: "C:\\Users\\posh", PathSeparator: "\\", GOOS: environment.WINDOWS},
// StackCountEnabled=true and StackCount=2
{Style: Full, FolderSeparatorIcon: "|", Pwd: "/", StackCount: 2, Expected: "2 /"},