From 31c949a495ff303f6ed319d2cd0547bb389ce408 Mon Sep 17 00:00:00 2001 From: Timo Borer Date: Sun, 18 Jan 2026 10:42:08 +0100 Subject: [PATCH] feat: Return correct result on empty query y now moves to ~ instead of /. The location can be configured by setting the LACY_NO_ARGS_PATH env variable. --- src/cmd/prompt.rs | 10 +++++++++- src/query.rs | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cmd/prompt.rs b/src/cmd/prompt.rs index 9e5ca23..d50d1aa 100644 --- a/src/cmd/prompt.rs +++ b/src/cmd/prompt.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, fs, path::PathBuf}; +use std::{collections::HashSet, env, fs, path::PathBuf}; use crate::{ cmd::{Prompt, Run}, @@ -11,6 +11,14 @@ impl Run for Prompt { fn run(&self) { let query = Query::from(self.query.clone()); + if query.parts().is_empty() { + println!( + "{}", + env::var("LACY_NO_ARGS_PATH").unwrap_or_else(|_| String::from("~")) + ); + return; + } + /* _ if first_query_part.starts_with("-") && !first_query_part diff --git a/src/query.rs b/src/query.rs index d3bdce2..a769d73 100644 --- a/src/query.rs +++ b/src/query.rs @@ -11,6 +11,12 @@ pub struct Query { impl From for Query { fn from(query: String) -> Self { let mut enhanced_query = query.clone().trim().replace(" ", " "); + if enhanced_query.trim().is_empty() { + return Query { + query, + parts: vec![], + }; + } if enhanced_query.starts_with("/") { enhanced_query = format!("##ROOT## {}", enhanced_query.strip_prefix("/").unwrap()); }