mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
parent
d10d568c15
commit
92031bdf51
|
@ -710,11 +710,20 @@ func (pt *Path) splitPath() Folders {
|
||||||
|
|
||||||
folderFormatMap := pt.makeFolderFormatMap()
|
folderFormatMap := pt.makeFolderFormatMap()
|
||||||
|
|
||||||
currentPath := pt.root
|
getCurrentPath := func() string {
|
||||||
if currentPath == "~" {
|
if pt.root == "~" {
|
||||||
currentPath = pt.env.Home() + pt.env.PathSeparator()
|
return pt.env.Home() + pt.env.PathSeparator()
|
||||||
|
}
|
||||||
|
|
||||||
|
if pt.env.GOOS() == platform.WINDOWS {
|
||||||
|
return pt.root + pt.env.PathSeparator()
|
||||||
|
}
|
||||||
|
|
||||||
|
return pt.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentPath := getCurrentPath()
|
||||||
|
|
||||||
var display bool
|
var display bool
|
||||||
|
|
||||||
for _, folder := range folders {
|
for _, folder := range folders {
|
||||||
|
|
|
@ -1506,6 +1506,7 @@ func TestReplaceMappedLocations(t *testing.T) {
|
||||||
func TestSplitPath(t *testing.T) {
|
func TestSplitPath(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Case string
|
Case string
|
||||||
|
GOOS string
|
||||||
Relative string
|
Relative string
|
||||||
Root string
|
Root string
|
||||||
GitDir *platform.FileInfo
|
GitDir *platform.FileInfo
|
||||||
|
@ -1517,6 +1518,7 @@ func TestSplitPath(t *testing.T) {
|
||||||
Case: "Regular directory",
|
Case: "Regular directory",
|
||||||
Root: "/",
|
Root: "/",
|
||||||
Relative: "c/d",
|
Relative: "c/d",
|
||||||
|
GOOS: platform.DARWIN,
|
||||||
Expected: Folders{
|
Expected: Folders{
|
||||||
{Name: "c", Path: "/c"},
|
{Name: "c", Path: "/c"},
|
||||||
{Name: "d", Path: "/c/d"},
|
{Name: "d", Path: "/c/d"},
|
||||||
|
@ -1526,6 +1528,7 @@ func TestSplitPath(t *testing.T) {
|
||||||
Case: "Home directory - git folder",
|
Case: "Home directory - git folder",
|
||||||
Root: "~",
|
Root: "~",
|
||||||
Relative: "c/d",
|
Relative: "c/d",
|
||||||
|
GOOS: platform.DARWIN,
|
||||||
GitDir: &platform.FileInfo{IsDir: true, ParentFolder: "/a/b/c"},
|
GitDir: &platform.FileInfo{IsDir: true, ParentFolder: "/a/b/c"},
|
||||||
GitDirFormat: "<b>%s</b>",
|
GitDirFormat: "<b>%s</b>",
|
||||||
Expected: Folders{
|
Expected: Folders{
|
||||||
|
@ -1533,6 +1536,20 @@ func TestSplitPath(t *testing.T) {
|
||||||
{Name: "d", Path: "/a/b/c/d"},
|
{Name: "d", Path: "/a/b/c/d"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Case: "Home directory - git folder on Windows",
|
||||||
|
Root: "C:",
|
||||||
|
Relative: "a/b/c/d",
|
||||||
|
GOOS: platform.WINDOWS,
|
||||||
|
GitDir: &platform.FileInfo{IsDir: true, ParentFolder: "C:/a/b/c"},
|
||||||
|
GitDirFormat: "<b>%s</b>",
|
||||||
|
Expected: Folders{
|
||||||
|
{Name: "a", Path: "C:/a"},
|
||||||
|
{Name: "b", Path: "C:/a/b"},
|
||||||
|
{Name: "<b>c</b>", Path: "C:/a/b/c", Display: true},
|
||||||
|
{Name: "d", Path: "C:/a/b/c/d"},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
@ -1540,6 +1557,7 @@ func TestSplitPath(t *testing.T) {
|
||||||
env.On("PathSeparator").Return("/")
|
env.On("PathSeparator").Return("/")
|
||||||
env.On("Home").Return("/a/b")
|
env.On("Home").Return("/a/b")
|
||||||
env.On("HasParentFilePath", ".git").Return(tc.GitDir, nil)
|
env.On("HasParentFilePath", ".git").Return(tc.GitDir, nil)
|
||||||
|
env.On("GOOS").Return(tc.GOOS)
|
||||||
path := &Path{
|
path := &Path{
|
||||||
env: env,
|
env: env,
|
||||||
props: properties.Map{
|
props: properties.Map{
|
||||||
|
|
Loading…
Reference in a new issue