Skip to content

Commit bb3b83f

Browse files
authored
fix: zoxide missing or no results (#13)
1 parent 9eb04dc commit bb3b83f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

zoxide/list.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ type ZoxideResult struct {
1818
func List(tmuxSessions []*tmux.TmuxSession) ([]*ZoxideResult, error) {
1919
output, err := zoxideCmd([]string{"query", "-ls"})
2020
if err != nil {
21-
return nil, err
21+
return []*ZoxideResult{}, nil
2222
}
2323
cleanOutput := strings.TrimSpace(string(output))
2424
list := strings.Split(cleanOutput, "\n")
25+
listLen := len(list)
26+
if listLen == 1 && list[0] == "" {
27+
return []*ZoxideResult{}, nil
28+
}
2529

26-
results := make([]*ZoxideResult, 0, len(list))
30+
results := make([]*ZoxideResult, 0, listLen)
2731
tmuxSessionPaths := make(map[string]struct{})
2832
for _, session := range tmuxSessions {
2933
tmuxSessionPaths[session.Path] = struct{}{}

0 commit comments

Comments
 (0)