From 65587d1eee9eddedafbba0ecd9c102d87149554f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 19 Oct 2020 21:01:18 +1100 Subject: Auto-insert best completion on space for menu completions The menu flag signifies that only the completions are valid arguments, hence it makes sense to auto insert the best one on space. Because full match is always considered the best match in completion ranking, this should always have a reasonable behaviour. This makes it harder to enter a hidden command, but completion can always be disabled via or by quoting in those rare cases. --- src/input_handler.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index c8333dda..ea3efb81 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -991,6 +991,15 @@ public: } else { + if (key == ' ' and + (m_completions.flags & Completions::Flags::Menu) and + not (m_completions.flags & Completions::Flags::Quoted) and + m_current_completion == -1 and not m_completions.candidates.empty()) + { + m_line_editor.insert_from(line.char_count_to(m_completions.start), + m_completions.candidates.front()); + } + m_line_editor.handle_key(key); clear_completions(); m_refresh_completion_pending = true; -- cgit v1.2.3