diff --git a/base/base/ReplxxLineReader.cpp b/base/base/ReplxxLineReader.cpp index 9e29f7744fa..261f0e2a16a 100644 --- a/base/base/ReplxxLineReader.cpp +++ b/base/base/ReplxxLineReader.cpp @@ -402,10 +402,11 @@ ReplxxLineReader::ReplxxLineReader( words.push_back(hs.get().text()); } + std::string current_query(rx.get_state().text()); std::string new_query; try { - new_query = std::string(skim(words)); + new_query = std::string(skim(current_query, words)); } catch (const std::exception & e) { diff --git a/rust/skim/include/skim.h b/rust/skim/include/skim.h index 12cd257567b..8148474eba3 100644 --- a/rust/skim/include/skim.h +++ b/rust/skim/include/skim.h @@ -87,4 +87,4 @@ private: } // namespace cxxbridge1 } // namespace rust -::rust::String skim(::std::vector<::std::string> const &words); +::rust::String skim(::std::string const &prefix, ::std::vector<::std::string> const &words); diff --git a/rust/skim/src/lib.rs b/rust/skim/src/lib.rs index 29160329287..90f39cc8382 100644 --- a/rust/skim/src/lib.rs +++ b/rust/skim/src/lib.rs @@ -5,7 +5,7 @@ use cxx::{CxxString, CxxVector}; #[cxx::bridge] mod ffi { extern "Rust" { - fn skim(words: &CxxVector) -> Result; + fn skim(prefix: &CxxString, words: &CxxVector) -> Result; } } @@ -18,7 +18,7 @@ impl SkimItem for Item { } } -fn skim(words: &CxxVector) -> Result { +fn skim(prefix: &CxxString, words: &CxxVector) -> Result { // Let's check is terminal available. To avoid panic. if let Err(err) = TermInfo::from_env() { return Err(format!("{}", err)); @@ -26,6 +26,7 @@ fn skim(words: &CxxVector) -> Result { let options = SkimOptionsBuilder::default() .height(Some("30%")) + .query(Some(prefix.to_str().unwrap())) .tac(true) .tiebreak(Some("-score".to_string())) .build()