-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completions not working #307
Comments
Keybindings are currently configured to require the completion menu. To use the completions you have to manually add it. Undocumented: Changing the keybindings to use the old bash style completions with `CircularCompletionHandler` Track nushell#307
Keybindings are currently configured to require the completion menu. To use the completions you have to manually add it. Undocumented: Changing the keybindings to use the old bash style completions with `CircularCompletionHandler` Track #307
Hi, the completion menu is still not working for me -Platform macos-aarch64 The example completions program compiles, runs, and displays a prompt. Typing a few characters then TAB or Ctrl+X does not complete the expected word or display a menu of possible completions. It appears to have the same behavior as without calling with_completions. Steps to reproduce -
use anyhow::Result;
use nu_ansi_term::{Color, Style};
use reedline::{
CompletionMenu, DefaultCompleter, DefaultHinter, DefaultPrompt, ExampleHighlighter,
FileBackedHistory, Reedline, Signal,
};
fn main() -> Result<()> {
let prompt = DefaultPrompt::default();
let history = Box::new(
FileBackedHistory::with_file(5, "history.txt".into())
.expect("Error configuring history with file"),
);
let commands = vec![
"test".into(),
"hello world".into(),
"hello world reedline".into(),
"this is the reedline crate".into(),
];
let completer = Box::new(DefaultCompleter::new(commands.clone()));
// Use the interactive menu to select options from the completer
let completion_menu = Box::new(CompletionMenu::default());
let mut line_editor = Reedline::create()?
.with_completer(completer)
.with_menu(completion_menu)
.with_history(history)
.expect("Error configuring reedline with history")
.with_highlighter(Box::new(ExampleHighlighter::new(commands)))
.with_hinter(Box::new(
DefaultHinter::default().with_style(Style::new().italic().fg(Color::LightGray)),
));
loop {
let sig = line_editor.read_line(&prompt)?;
match sig {
Signal::Success(buffer) => {
println!("We processed: {}", buffer);
}
Signal::CtrlD | Signal::CtrlC => {
println!("\nAborted!");
break Ok(());
}
Signal::CtrlL => {
line_editor.clear_screen().unwrap();
}
}
}
} |
I should have dug around the new commits after release more, I think I got it to work after reading |
Mhh @elferherrera, did something relating the general API change with your latest menu changes? |
Not really. @DhruvDh when you say the list menu doesn't work, what do you mean? |
Sorry for not having a minimal reproduction, but this is from the repo https://github.com/DhruvDh/umm/tree/next at https://github.com/DhruvDh/umm/blob/next/src/main.rs. This is how I am creating a line editor - https://github.com/DhruvDh/umm/blob/06f046abbaa1dc2500692c70c7d05b846d358b8a/src/main.rs#L61-L103 let mut line_editor = Reedline::create()
.with_history(Box::new(
FileBackedHistory::with_file(5, "history.txt".into())
.expect("Error configuring history with file"),
))
.with_highlighter(Box::new(ExampleHighlighter::new(commands.clone())))
.with_hinter(Box::new(
DefaultHinter::default().with_style(Style::new().italic().fg(Color::LightGray)),
))
.with_completer({
let mut inclusions = vec!['-', '_'];
for i in '0'..='9' {
inclusions.push(i);
}
let mut completer = DefaultCompleter::with_inclusions(&inclusions);
completer.insert(commands.clone());
Box::new(completer)
})
.with_quick_completions(true)
.with_partial_completions(true)
.with_ansi_colors(true)
.with_menu(ReedlineMenu::EngineCompleter(Box::new(
ListMenu::default().with_name("completion_menu"),
)))
.with_edit_mode({
let mut keybindings = default_emacs_keybindings();
keybindings.add_binding(
KeyModifiers::NONE,
KeyCode::Tab,
ReedlineEvent::UntilFound(vec![
ReedlineEvent::Menu("completion_menu".to_string()),
ReedlineEvent::MenuNext,
]),
);
keybindings.add_binding(
KeyModifiers::SHIFT,
KeyCode::BackTab,
ReedlineEvent::MenuPrevious,
);
Box::new(Emacs::new(keybindings))
}); With With I will add a minimal reproduction later as soon as I have time, sorry. |
I see what is happening. The list type of menu doesn't take as input what is already written, but what you write after you activate it. Try to trigger the menu and then type something. I'm writing a chapter to explain the differences between these menus and how they can be used with different completers Another option is to create the menu and then use this function with the constructor
That should that what has been written |
Ah, thank you. I figured I probably was using it incorrectly. Anyway the library is great! Thanks for all of your guys' work. |
Hello all, |
Platform linux
Terminal software rxvt-unicode
The example completions program compiles, runs, and displays a prompt. Typing a few characters then
TAB
orCtrl+X
does not complete the expected word or display a menu of possible completions. It appears to have the same behavior as without callingwith_completions
.Steps to reproduce
I did this today so I believe it's 8c565e4 though I don't know how to confirm this in the project.
The text was updated successfully, but these errors were encountered: