Skip to content

Conversation

@markjaquith
Copy link
Contributor

fixes #249

Warning

Be gentle: this is the first Go code I've written

Note

Using slices.Delete was recommended by the linter as the modern way, versus slicing around the range you want to delete, so I went with that.

@markjaquith markjaquith marked this pull request as draft April 24, 2025 21:15
@markjaquith markjaquith marked this pull request as ready for review April 24, 2025 21:26
for i, index := range fullOrderedIndex {
if fullDirectory[index].Name == attachedSession.Name {
fullOrderedIndex = slices.Delete(fullOrderedIndex, i, i+1)
break
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Does it seem right to break here? Is it possible to have two sessions with the same .Name?
  2. If it's not possible to have two sessions with the same .Name, isn't the active session always first in the list? So Couldn't I skip the iteration and just check fullDirectory[fullOrderedIndex[0]].Name against attachedSession.Name to save a bunch of CPU cycles?

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some related code got merged recently, can you confirm that main still has the same issue?

@joshmedeski
Copy link
Owner

@markjaquith flagging this again. A bit has been merged, can you confirm the issue is still present?

@joshmedeski
Copy link
Owner

Hey @markjaquith are you still seeing this issue?

@markjaquith
Copy link
Contributor Author

I created /tmp/foo and then created a session in that dir. Seems like the issue still exists.

 ❯ pwd
/tmp/foo
 ❯ sesh list | grep foo
foo
/tmp/foo
 ❯ sesh list --hide-duplicates | grep foo
foo
 ❯ sesh list --hide-attached | grep foo
/tmp/foo
 ❯ sesh list --hide-attached --hide-duplicates | grep foo
/tmp/foo

I still think that if I'm hiding the attached and also hiding duplicates, that every duplicate of the attached session directory should be hidden. What I'm trying to accomplish is:

  1. I don't want to see my active session anywhere in the list.
  2. I want each directory to appear a maximum of once... if there is a session for it, it should show there. If not, and there is a config, then in config. If there is not a session or a config, then in zoxide list.

@joshmedeski
Copy link
Owner

Thanks for the feedback, does this PR confirm it fixes it?

@joshmedeski
Copy link
Owner

I manually tested this and it appears to be working as expected, thanks!

@joshmedeski joshmedeski merged commit 33c0eda into joshmedeski:main Nov 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--hide-duplicates doesn't hide Zoxide duplicate of currently attached session when passing --hide-attached

2 participants