fix prompt completion handling misbehaving with history

This commit is contained in:
Maxime Coste 2013-11-28 18:44:42 +00:00
parent b83414ddf7
commit 50325e62b0

View File

@ -386,6 +386,9 @@ public:
break; break;
} }
} while (it != history.begin()); } while (it != history.begin());
clear_completions();
showcompl = true;
} }
} }
else if (key == Key::Down or key == ctrl('n')) // next else if (key == Key::Down or key == ctrl('n')) // next
@ -402,6 +405,9 @@ public:
m_line_editor.reset(*m_history_it); m_line_editor.reset(*m_history_it);
else else
m_line_editor.reset(m_prefix); m_line_editor.reset(m_prefix);
clear_completions();
showcompl = true;
} }
} }
else if (key == ctrl('i') or key == Key::BackTab) // tab completion else if (key == ctrl('i') or key == Key::BackTab) // tab completion
@ -455,9 +461,7 @@ public:
else else
{ {
m_line_editor.handle_key(key); m_line_editor.handle_key(key);
m_current_completion = -1; clear_completions();
if (context().has_ui())
context().ui().menu_hide();
showcompl = true; showcompl = true;
} }
@ -502,6 +506,13 @@ private:
} catch (runtime_error&) {} } catch (runtime_error&) {}
} }
void clear_completions()
{
m_current_completion = -1;
if (context().has_ui())
context().ui().menu_hide();
}
void display() const void display() const
{ {
auto display_line = m_line_editor.build_display_line(); auto display_line = m_line_editor.build_display_line();