Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make matching behavior slightly more intuitive #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anachrome
Copy link

normal z matching behavior, especially with respect to the common() function, is a little odd:

mkdir -p aaa/bbb
cd aaa
cd -
cd aaa/bbb
cd -
z aaa # goes to aaa, even though aaa/bbb has higher frecency
cd -
mkdir -p zzz/aaa
cd zzz/aaa
cd -
cd aaa/bbb
cd -
cd aaa/bbb # increasing the frecency of the subdir
cd -
z aaa # goes to ./aaa/bbb (deeper in the directory tree than I am trying to jump)

In fact, if an unrelated path matching /aaa/ is in z's database, and aaa/bbb is of higher frecency than aaa, there is no way to jump to aaa without also jumping deeper into aaa/bbb.

This patch changes the matching behavior so z will only jump to a deeper directory if it is explicitly matched - e.g., z aaa will never jump below the directory matching aaa, which I find to be slightly more intuitive.

a path is now considered to match a regex iff at least part of the regex
matches the basename of the path - this obviates the need for the common
function, since now if there is a common parent path, it will usually be the
best match.
@GammaGames
Copy link

I was wondering if anyone had a fix for this behavior, using z modules to try and go to a modules folder almost always takes me to modules/app1 or modules/app2, depending on which one I was in recently. I saw @rupa merged another request recently, I wonder if he has any thoughts on this one?

@rupa
Copy link
Owner

rupa commented Oct 10, 2019

yeah, i should really think about merging this. at the very least, it gets rid of the code i hate most. definitely some "i have this problem and this fixes it and doesn't make anything else worse" comments help :)

@GammaGames
Copy link

GammaGames commented Oct 10, 2019

I’ll put it on my computer and test it for a week or two, I use z a handful of times a day so I think it would be a decent indicator of real world use. Thank you!

Edit: There have been significant changes since this was submitted, I'll try to get all the changes into a branch that works first. Then I'll test it out

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.

3 participants