Fix InputMode::Prompt blocking behaviour when inserting register

This commit is contained in:
Maxime Coste 2012-11-07 20:36:45 +01:00
parent a6f0d53dbf
commit 7dc634444d

View File

@ -243,7 +243,14 @@ public:
{ {
std::vector<String>& history = ms_history[m_prompt]; std::vector<String>& history = ms_history[m_prompt];
const String& line = m_line_editor.line(); const String& line = m_line_editor.line();
if (key == Key{Key::Modifiers::Control, 'm'}) // enter
if (m_insert_reg)
{
String reg = RegisterManager::instance()[key.key].values(context)[0];
m_line_editor.insert(reg);
m_insert_reg = false;
}
else if (key == Key{Key::Modifiers::Control, 'm'}) // enter
{ {
std::vector<String>::iterator it; std::vector<String>::iterator it;
while ((it = find(history, line)) != history.end()) while ((it = find(history, line)) != history.end())
@ -267,9 +274,7 @@ public:
} }
else if (key == Key{Key::Modifiers::Control, 'r'}) else if (key == Key{Key::Modifiers::Control, 'r'})
{ {
Key k = context.ui().get_key(); m_insert_reg = true;
String reg = RegisterManager::instance()[k.key].values(context)[0];
m_line_editor.insert(reg);
} }
else if (key == Key::Up or else if (key == Key::Up or
key == Key{Key::Modifiers::Control, 'p'}) key == Key{Key::Modifiers::Control, 'p'})
@ -362,6 +367,7 @@ private:
int m_current_completion = -1; int m_current_completion = -1;
String m_prefix; String m_prefix;
LineEditor m_line_editor; LineEditor m_line_editor;
bool m_insert_reg = false;
static std::unordered_map<String, std::vector<String>> ms_history; static std::unordered_map<String, std::vector<String>> ms_history;
std::vector<String>::iterator m_history_it; std::vector<String>::iterator m_history_it;