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()); }