feat(path): use second letter for .folder

resolves #886
This commit is contained in:
Jan De Dobbeleer 2021-08-09 20:36:26 +02:00 committed by Jan De Dobbeleer
parent 84183b7506
commit 68f576692b
2 changed files with 11 additions and 3 deletions

View file

@ -149,11 +149,17 @@ func (pt *path) getLetterPath() string {
splitted := strings.Split(pwd, pt.env.getPathSeperator()) splitted := strings.Split(pwd, pt.env.getPathSeperator())
separator := pt.props.getString(FolderSeparatorIcon, pt.env.getPathSeperator()) separator := pt.props.getString(FolderSeparatorIcon, pt.env.getPathSeperator())
for i := 0; i < len(splitted)-1; i++ { for i := 0; i < len(splitted)-1; i++ {
if len(splitted[i]) == 0 { folder := splitted[i]
if len(folder) == 0 {
continue continue
} }
letter := []rune(splitted[i])[0] var letter string
buffer.WriteString(fmt.Sprintf("%c%s", letter, separator)) if strings.HasPrefix(folder, ".") && len(folder) > 1 {
letter = folder[0:2]
} else {
letter = folder[0:1]
}
buffer.WriteString(fmt.Sprintf("%s%s", letter, separator))
} }
buffer.WriteString(splitted[len(splitted)-1]) buffer.WriteString(splitted[len(splitted)-1])
return buffer.String() return buffer.String()

View file

@ -299,6 +299,8 @@ func TestAgnosterPathStyles(t *testing.T) {
{Style: Letter, Expected: "~ > a > w > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "}, {Style: Letter, Expected: "~ > a > w > man", HomePath: "/usr/home", Pwd: "/usr/home/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: Letter, Expected: "u > b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "}, {Style: Letter, Expected: "u > b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: Letter, Expected: "u > .b > a > w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
{Style: Letter, Expected: "u > .b > a > .w > man", HomePath: "/usr/home", Pwd: "/usr/.burp/ab/.whatever/man", PathSeperator: "/", FolderSeparatorIcon: " > "},
} }
for _, tc := range cases { for _, tc := range cases {
env := new(MockedEnvironment) env := new(MockedEnvironment)