Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle the case where get_current_dir returns Err
  • Loading branch information
p00f committed Oct 17, 2023
commit 3e02a1e0dc769732b016caeb0c34c31cc5a0f97a
21 changes: 13 additions & 8 deletions src/history/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,19 @@ impl SearchQuery {
prefix: String,
session: Option<HistorySessionId>,
) -> SearchQuery {
SearchQuery::last_with_search(SearchFilter::from_text_search_cwd(
std::env::current_dir()
.unwrap()
.to_string_lossy()
.to_string(),
CommandLineSearch::Prefix(prefix),
session,
))
let cwd = std::env::current_dir();
if let Ok(cwd) = cwd {
SearchQuery::last_with_search(SearchFilter::from_text_search_cwd(
cwd.to_string_lossy().to_string(),
CommandLineSearch::Prefix(prefix),
session,
))
} else {
SearchQuery::last_with_search(SearchFilter::from_text_search(
CommandLineSearch::Prefix(prefix),
session,
))
}
}

/// Query to get all entries in the given [`SearchDirection`]
Expand Down