diff options
| author | Maxime Coste <mawww@kakoune.org> | 2020-11-01 10:32:44 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2020-11-01 10:32:44 +1100 |
| commit | aab0be529f77f3a8e86185a030838e6d547d0286 (patch) | |
| tree | 30b793243c639eb48bcd9b05c9327f2d27a4450e /src/input_handler.cc | |
| parent | f25442fbad826c074e8ec339b622e092eab3d3fd (diff) | |
Auto-insert prompt menu completions on <ret> if any text was entered
Previously we would only auto-insert if the current token had some
text, but this breaks auto-selection of the first match.
Fixes #3849
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index f4376ae2..552eef0d 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -771,16 +771,16 @@ public: { const String& line = m_line_editor.line(); - auto can_auto_insert_completion = [&] { + auto can_auto_insert_completion = [&] (bool check_token) { const bool has_completions = not m_completions.candidates.empty(); const bool completion_selected = m_current_completion != -1; - const bool text_entered = m_completions.start != line.byte_count_to(m_line_editor.cursor_pos()); + const bool text_entered = check_token ? m_completions.start != line.byte_count_to(m_line_editor.cursor_pos()) : !line.empty(); return has_completions and not completion_selected and text_entered; }; if (key == Key::Return) { - if ((m_completions.flags & Completions::Flags::Menu) and can_auto_insert_completion()) + if ((m_completions.flags & Completions::Flags::Menu) and can_auto_insert_completion(false)) { const String& completion = m_completions.candidates.front(); m_line_editor.insert_from(line.char_count_to(m_completions.start), @@ -999,7 +999,7 @@ public: if (key == ' ' and (m_completions.flags & Completions::Flags::Menu) and not (m_completions.flags & Completions::Flags::Quoted) and // if token is quoted, this space does not end it - can_auto_insert_completion()) + can_auto_insert_completion(true)) m_line_editor.insert_from(line.char_count_to(m_completions.start), m_completions.candidates.front()); |
