From f67ee8e60973cc92cdb2696b8a0ab5970c36cf82 Mon Sep 17 00:00:00 2001 From: lnu Date: Thu, 30 Sep 2021 10:29:17 +0200 Subject: [PATCH] fix(path): display root path icon when using agnoster --- src/segment_path.go | 2 +- src/segment_path_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/segment_path.go b/src/segment_path.go index 7c1aa480abb9..1c8fe6a848e0 100644 --- a/src/segment_path.go +++ b/src/segment_path.go @@ -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) diff --git a/src/segment_path_test.go b/src/segment_path_test.go index c626a7c663c8..46f69b9a2d69 100644 --- a/src/segment_path_test.go +++ b/src/segment_path_test.go @@ -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},