diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-03-24 21:44:14 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-03-24 21:44:14 +0000 |
| commit | bbdb2494d1f8063716d439a0e47d111e6e0c5f65 (patch) | |
| tree | ae38508c98cbd1e7b55b3476d5162a060a5fc19b /src | |
| parent | defd0f99b1b40ed3c0881462941402f54afe5563 (diff) | |
| parent | 369728cd7fbcda19babe64e1b0d0e7524a4705fa (diff) | |
Merge remote-tracking branch 'evertvp/master'
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_handler.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index f275af23..2613215f 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -337,6 +337,18 @@ String common_prefix(memoryview<String> strings) return res; } +void history_push(std::vector<String>& history, const String& entry) +{ + if(entry.empty()) + { + return; + } + std::vector<String>::iterator it; + while ((it = find(history, entry)) != history.end()) + history.erase(it); + history.push_back(entry); +} + class Prompt : public InputMode { public: @@ -365,13 +377,7 @@ public: } else if (key == ctrl('m')) // enter { - if (not line.empty()) - { - std::vector<String>::iterator it; - while ((it = find(history, line)) != history.end()) - history.erase(it); - history.push_back(line); - } + history_push(history, line); context().print_status(DisplayLine{}); if (context().has_ui()) context().ui().menu_hide(); @@ -383,6 +389,7 @@ public: } else if (key == Key::Escape or key == ctrl('c')) { + history_push(history, line); context().print_status(DisplayLine{}); if (context().has_ui()) context().ui().menu_hide(); |
