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.
This commit is contained in:
parent
052d877ee6
commit
cf2609de1c
|
@ -451,12 +451,14 @@ public:
|
||||||
const bool reverse = (key == Key::BackTab);
|
const bool reverse = (key == Key::BackTab);
|
||||||
CandidateList& candidates = m_completions.candidates;
|
CandidateList& candidates = m_completions.candidates;
|
||||||
// first try, we need to ask our completer for completions
|
// first try, we need to ask our completer for completions
|
||||||
|
bool updated_completions = false;
|
||||||
if (candidates.empty())
|
if (candidates.empty())
|
||||||
{
|
{
|
||||||
refresh_completions(CompletionFlags::None);
|
refresh_completions(CompletionFlags::None);
|
||||||
|
|
||||||
if (candidates.empty())
|
if (candidates.empty())
|
||||||
return;
|
return;
|
||||||
|
updated_completions = true;
|
||||||
}
|
}
|
||||||
bool did_prefix = false;
|
bool did_prefix = false;
|
||||||
if (m_current_completion == -1 and
|
if (m_current_completion == -1 and
|
||||||
|
@ -481,7 +483,10 @@ public:
|
||||||
m_current_completion = it - candidates.begin();
|
m_current_completion = it - candidates.begin();
|
||||||
|
|
||||||
CharCount start = line.char_count_to(m_completions.start);
|
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)
|
if (not did_prefix)
|
||||||
|
@ -545,6 +550,7 @@ private:
|
||||||
{
|
{
|
||||||
if (not m_completer)
|
if (not m_completer)
|
||||||
return;
|
return;
|
||||||
|
m_current_completion = -1;
|
||||||
const String& line = m_line_editor.line();
|
const String& line = m_line_editor.line();
|
||||||
m_completions = m_completer(context(), flags, line,
|
m_completions = m_completer(context(), flags, line,
|
||||||
line.byte_count_to(m_line_editor.cursor_pos()));
|
line.byte_count_to(m_line_editor.cursor_pos()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user