summaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorPeter Holloway <holloway.p.r@gmail.com>2024-01-19 11:21:05 +0000
committerGitHub <noreply@github.com>2024-01-19 11:21:05 +0000
commit10f465da8ff113819d435b0f8e5066783c5100af (patch)
tree4d2fd5a07159ae932bc3f871638501bc801777e9 /atuin-client
parent62f81a8c9125ada94e6004d49428befaf6caec9e (diff)
fix: Use existing db querying for history list (#1589)
When printing the history list with either the session or cwd filter enabled, use to same query method as without either to ensure that the other options (hide deleted entries etc) are respected.
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/src/database.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs
index a69570931..05ff559a4 100644
--- a/atuin-client/src/database.rs
+++ b/atuin-client/src/database.rs
@@ -78,7 +78,7 @@ pub trait Database: Send + Sync + 'static {
async fn load(&self, id: &str) -> Result<Option<History>>;
async fn list(
&self,
- filter: FilterMode,
+ filters: &[FilterMode],
context: &Context,
max: Option<usize>,
unique: bool,
@@ -271,7 +271,7 @@ impl Database for Sqlite {
// make a unique list, that only shows the *newest* version of things
async fn list(
&self,
- filter: FilterMode,
+ filters: &[FilterMode],
context: &Context,
max: Option<usize>,
unique: bool,
@@ -291,13 +291,15 @@ impl Database for Sqlite {
context.cwd.clone()
};
- match filter {
- FilterMode::Global => &mut query,
- FilterMode::Host => query.and_where_eq("hostname", quote(&context.hostname)),
- FilterMode::Session => query.and_where_eq("session", quote(&context.session)),
- FilterMode::Directory => query.and_where_eq("cwd", quote(&context.cwd)),
- FilterMode::Workspace => query.and_where_like_left("cwd", git_root),
- };
+ for filter in filters {
+ match filter {
+ FilterMode::Global => &mut query,
+ FilterMode::Host => query.and_where_eq("hostname", quote(&context.hostname)),
+ FilterMode::Session => query.and_where_eq("session", quote(&context.session)),
+ FilterMode::Directory => query.and_where_eq("cwd", quote(&context.cwd)),
+ FilterMode::Workspace => query.and_where_like_left("cwd", &git_root),
+ };
+ }
if unique {
query.and_where_eq(