From e28ee8ad90036d6b1a05878d0be193f81e516423 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Tue, 26 Mar 2024 15:00:19 +0100 Subject: [PATCH 1/2] Make cwd prefix case sensitive as well Discuss: - Windows FS operations can be case-insensitive for the user - Can the actual operations through which we gather the `cwd` return different case? --- src/history/sqlite_backed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/history/sqlite_backed.rs b/src/history/sqlite_backed.rs index ec3b021a..36d8fc7c 100644 --- a/src/history/sqlite_backed.rs +++ b/src/history/sqlite_backed.rs @@ -349,8 +349,8 @@ impl SqliteBackedHistory { params.push((":cwd", Box::new(cwd_exact))); } if let Some(cwd_prefix) = &query.filter.cwd_prefix { - wheres.push("cwd like :cwd_like"); - let cwd_like = format!("{cwd_prefix}%"); + wheres.push("cwd glob :cwd_like"); + let cwd_like = format!("{cwd_prefix}*"); params.push((":cwd_like", Box::new(cwd_like))); } if let Some(exit_successful) = query.filter.exit_successful { From e5638446f9b6b83de65cd49de0d778a8ede76385 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Tue, 26 Mar 2024 15:34:40 +0100 Subject: [PATCH 2/2] Use `instr` for cwd as well --- src/history/sqlite_backed.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/history/sqlite_backed.rs b/src/history/sqlite_backed.rs index 36d8fc7c..50e678b5 100644 --- a/src/history/sqlite_backed.rs +++ b/src/history/sqlite_backed.rs @@ -349,9 +349,8 @@ impl SqliteBackedHistory { params.push((":cwd", Box::new(cwd_exact))); } if let Some(cwd_prefix) = &query.filter.cwd_prefix { - wheres.push("cwd glob :cwd_like"); - let cwd_like = format!("{cwd_prefix}*"); - params.push((":cwd_like", Box::new(cwd_like))); + wheres.push("instr(cwd, :cwd_like) == 1"); + params.push((":cwd_like", Box::new(cwd_prefix))); } if let Some(exit_successful) = query.filter.exit_successful { if exit_successful {