diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-06-09 13:44:45 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-06-09 13:47:37 +0100 |
| commit | cf2609de1ce80e069045bc4f567c79d22345ca39 (patch) | |
| tree | c5febccd7e892d57a53d46a49fe676aa066ad91c /src/input_handler.cc | |
| parent | 052d877ee64a0002dde538ae8f9a11da54f89191 (diff) | |
Tweak prompt completion behaviour
Always select the common prefix if we just updated the list of
completions. The previous behaviour was to ignore it if we had
it already typed. Do that only if it was already displayed.
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 523a1660..ee136e24 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -451,12 +451,14 @@ public: const bool reverse = (key == Key::BackTab); CandidateList& candidates = m_completions.candidates; // first try, we need to ask our completer for completions + bool updated_completions = false; if (candidates.empty()) { refresh_completions(CompletionFlags::None); if (candidates.empty()) return; + updated_completions = true; } bool did_prefix = false; if (m_current_completion == -1 and @@ -481,7 +483,10 @@ public: m_current_completion = it - candidates.begin(); CharCount start = line.char_count_to(m_completions.start); - did_prefix = prefix != line.substr(start, m_line_editor.cursor_pos() - start); + // When we just updated completions, select the common + // prefix even if it was the currently entered text. + did_prefix = updated_completions or + prefix != line.substr(start, m_line_editor.cursor_pos() - start); } } if (not did_prefix) @@ -545,6 +550,7 @@ private: { if (not m_completer) return; + m_current_completion = -1; const String& line = m_line_editor.line(); m_completions = m_completer(context(), flags, line, line.byte_count_to(m_line_editor.cursor_pos())); |
