-
Notifications
You must be signed in to change notification settings - Fork 75
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
--in
option doesn't distinguish between subdir and partial path match
#54
Comments
You are quite right - I'll have a look at the pattern handling in sqlite and see whether this can be improved. |
I think the following will work, right? It will match the exact directory or the directory name followed by a slash, then any other characters. diff --git a/sqlite-history.zsh b/sqlite-history.zsh
index 32c3990..87b3ff4 100644
--- a/sqlite-history.zsh
+++ b/sqlite-history.zsh
@@ -305,7 +305,7 @@ histdb () {
local dir=""
for dir ($indirs); do
dir="${${${dir#--in}#=}:-$PWD}"
- dirwhere="${dirwhere}${dirwhere:+ or }places.dir like '$(sql_escape $dir)%'"
+ dirwhere="${dirwhere}${dirwhere:+ or }places.dir = '$(sql_escape $dir)%' or places.dir like '$(sql_escape $dir/)%'"
done
for dir ($atdirs); do
dir="${${${dir#--at}#=}:-$PWD}" |
This looks correct, thanks - I will apply this change. |
Oops, there is a mistake there. I accidentally left the percent sign on the first comparison. It should be: diff --git a/sqlite-history.zsh b/sqlite-history.zsh
index 32c3990..87b3ff4 100644
--- a/sqlite-history.zsh
+++ b/sqlite-history.zsh
@@ -305,7 +305,7 @@ histdb () {
local dir=""
for dir ($indirs); do
dir="${${${dir#--in}#=}:-$PWD}"
- dirwhere="${dirwhere}${dirwhere:+ or }places.dir like '$(sql_escape $dir)%'"
+ dirwhere="${dirwhere}${dirwhere:+ or }places.dir = '$(sql_escape $dir)' or places.dir like '$(sql_escape $dir/)%'"
done
for dir ($atdirs); do
dir="${${${dir#--at}#=}:-$PWD}" |
If I call
histdb --in
while in~/dev/vim
, it yields results from~/dev/vim
as well as~/dev/vimrc
. I assume the logic that is meant to handle the "current dir or below" logic is using some kind of simple substring matching, therefore seeing~/dev/vimrc
as including the substring~/dev/vim
and returning a match.In fact, it seems that's exactly what's happening:
zsh-histdb/sqlite-history.zsh
Line 220 in 0a7a52a
The text was updated successfully, but these errors were encountered: