Skip to content

make matching behavior slightly more intuitive#157

Open
tlilyh wants to merge 1 commit intorupa:masterfrom
tlilyh:master
Open

make matching behavior slightly more intuitive#157
tlilyh wants to merge 1 commit intorupa:masterfrom
tlilyh:master

Conversation

@tlilyh
Copy link

@tlilyh tlilyh commented Aug 11, 2015

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