kkawakam / rustyline

Readline Implementation in Rust
https://crates.io/crates/rustyline/
MIT License
1.5k stars 173 forks source link

Support completion candidates that are shorter than the input #750

Closed gwenn closed 7 months ago

gwenn commented 7 months ago

Fix #748

sharkdp commented 7 months ago

This works great — thank you very much!

I had to patch rustyline-derive in order for this branch to compile (not sure if this is the right fix though):

diff --git a/rustyline-derive/src/lib.rs b/rustyline-derive/src/lib.rs
index 5f57060..c25e616 100644
--- a/rustyline-derive/src/lib.rs
+++ b/rustyline-derive/src/lib.rs
@@ -126,8 +126,8 @@ pub fn highlighter_macro_derive(input: TokenStream) -> TokenStream {
                     ::rustyline::highlight::Highlighter::highlight_candidate(&self.#field_name_or_index, candidate, completion)
                 }

-                fn highlight_char(&self, line: &str, pos: usize) -> bool {
-                    ::rustyline::highlight::Highlighter::highlight_char(&self.#field_name_or_index, line, pos)
+                fn highlight_char(&self, line: &str, pos: usize, forced: bool) -> bool {
+                    ::rustyline::highlight::Highlighter::highlight_char(&self.#field_name_or_index, line, pos, forced)
                 }
             }
         }
gwenn commented 7 months ago

I had to patch rustyline-derive in order for this branch to compile (not sure if this is the right fix though):

Indeed, I don't understand why there is no error when examples are compiled ! Currently, there is no check / usage of get_field_by_attr(&input.data, "Highlighter")