Skip to content

Commit

Permalink
made partial completions only occur when adding more than the input s…
Browse files Browse the repository at this point in the history
…tring (#834)
  • Loading branch information
uek-1 authored Oct 7, 2024
1 parent 4634f71 commit 871075e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,17 +967,17 @@ impl Reedline {
}
ReedlineEvent::MenuNext => {
if let Some(menu) = self.menus.iter_mut().find(|menu| menu.is_active()) {
if self.partial_completions {
menu.can_partially_complete(
self.quick_completions,
&mut self.editor,
self.completer.as_mut(),
self.history.as_ref(),
);
};
if menu.get_values().len() == 1 && menu.can_quick_complete() {
self.handle_editor_event(prompt, ReedlineEvent::Enter)
} else {
if self.partial_completions {
menu.can_partially_complete(
self.quick_completions,
&mut self.editor,
self.completer.as_mut(),
self.history.as_ref(),
);
}
menu.menu_event(MenuEvent::NextElement);
Ok(EventStatus::Handled)
}
Expand Down
3 changes: 2 additions & 1 deletion src/menu/menu_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ pub fn can_partially_complete(values: &[Suggestion], editor: &mut Editor) -> boo
let matching = &value[0..index];

// make sure that the partial completion does not overwrite user entered input
let extends_input = matching.starts_with(&editor.get_buffer()[span.start..span.end]);
let extends_input = matching.starts_with(&editor.get_buffer()[span.start..span.end])
&& matching != &editor.get_buffer()[span.start..span.end];

if !matching.is_empty() && extends_input {
let mut line_buffer = editor.line_buffer().clone();
Expand Down

0 comments on commit 871075e

Please sign in to comment.