fix(path): display root path icon when using agnoster

This commit is contained in:
lnu 2021-09-30 10:29:17 +02:00 committed by Jan De Dobbeleer
parent 44b970fc02
commit f67ee8e609
2 changed files with 2 additions and 2 deletions

View file

@ -169,7 +169,7 @@ func (pt *path) getLetterPath() string {
func (pt *path) getAgnosterFullPath() string {
pwd := pt.getPwd()
if string(pwd[0]) == pt.env.getPathSeperator() {
if len(pwd) > 1 && string(pwd[0]) == pt.env.getPathSeperator() {
pwd = pwd[1:]
}
return pt.replaceFolderSeparators(pwd)

View file

@ -305,7 +305,7 @@ func TestAgnosterPathStyles(t *testing.T) {
{Style: AgnosterShort, Expected: "~ > .. > man", HomePath: "/usr/home", Pwd: "/usr/home/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "~ > projects", HomePath: "/usr/home", Pwd: "/usr/home/projects", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "C:", HomePath: homeBillWindows, Pwd: "C:", PathSeperator: "\\", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "", HomePath: homeBillWindows, Pwd: "/", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "/", HomePath: homeBillWindows, Pwd: "/", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "foo", HomePath: homeBillWindows, Pwd: "/foo", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "usr > .. > bar > man", HomePath: "/usr/home", Pwd: "/usr/foo/bar/man", PathSeperator: "/", FolderSeparatorIcon: " > ", MaxDepth: 2},