diff --git a/main.go b/main.go index 94e3d9a..2c28316 100644 --- a/main.go +++ b/main.go @@ -5364,7 +5364,7 @@ func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) { return indices }() } - if u.mode != "phone" || len(displayPath) <= 1 { + if u.mode != "phone" || len(displayPath) <= 2 { crumbs := append([]string{"/"}, append([]string{}, displayPath...)...) indices := make([]int, 0, len(crumbs)) indices = append(indices, 0) @@ -5373,9 +5373,6 @@ func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) { } return crumbs, indices } - if len(displayPath) == 2 { - return []string{"/", displayPath[len(displayPath)-1]}, []int{0, len(displayPath)} - } crumbs := []string{"/", "…", displayPath[len(displayPath)-1]} indices := []int{0, len(displayPath) - 1, len(displayPath)} return crumbs, indices diff --git a/main_test.go b/main_test.go index 748c393..61565e5 100644 --- a/main_test.go +++ b/main_test.go @@ -5197,11 +5197,11 @@ func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) { u := newUIWithModel("phone", vault.Model{}) gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Root", "Infrastructure"}) - if !slices.Equal(gotCrumbs, []string{"/", "Infrastructure"}) { - t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Infrastructure]", gotCrumbs) + if !slices.Equal(gotCrumbs, []string{"/", "Root", "Infrastructure"}) { + t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Root Infrastructure]", gotCrumbs) } - if !slices.Equal(gotIndices, []int{0, 2}) { - t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 2]", gotIndices) + if !slices.Equal(gotIndices, []int{0, 1, 2}) { + t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 1 2]", gotIndices) } gotCrumbs, gotIndices = u.visibleBreadcrumbs([]string{"Root", "Infrastructure", "SSH"}) @@ -5213,6 +5213,19 @@ func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) { } } +func TestUIPhoneVisibleBreadcrumbsKeepParentForTwoSegmentPath(t *testing.T) { + t.Parallel() + + u := newUIWithModel("phone", vault.Model{}) + gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Joe", "Internet"}) + if !slices.Equal(gotCrumbs, []string{"/", "Joe", "Internet"}) { + t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Joe Internet]", gotCrumbs) + } + if !slices.Equal(gotIndices, []int{0, 1, 2}) { + t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 1 2]", gotIndices) + } +} + func TestUILocalLifecycleActionErrorsAreVisibleAndSpecific(t *testing.T) { t.Parallel()