diff options
Diffstat (limited to 'FreeFileSync/Source/ui/command_box.cpp')
-rwxr-xr-x | FreeFileSync/Source/ui/command_box.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/FreeFileSync/Source/ui/command_box.cpp b/FreeFileSync/Source/ui/command_box.cpp index 81a0aa6f..9d8c7a9b 100755 --- a/FreeFileSync/Source/ui/command_box.cpp +++ b/FreeFileSync/Source/ui/command_box.cpp @@ -22,7 +22,7 @@ inline std::wstring getSeparationLine() { return std::wstring(50, EM_DASH); } //no space between dashes! -std::vector<std::pair<std::wstring, Zstring>> getDefaultCommands() //(gui name/command) pairs +std::vector<std::pair<std::wstring, Zstring>> getDefaultCommands() //(description/command) pairs { return { @@ -63,21 +63,21 @@ CommandBox::CommandBox(wxWindow* parent, void CommandBox::addItemHistory() { - const Zstring command = trimCpy(getValue()); + const Zstring newCommand = trimCpy(getValue()); - if (command == utfTo<Zstring>(getSeparationLine()) || //do not add sep. line - command.empty()) + if (newCommand == utfTo<Zstring>(getSeparationLine()) || //do not add sep. line + newCommand.empty()) return; //do not add built-in commands to history - for (const auto& item : defaultCommands_) - if (command == utfTo<Zstring>(item.first) || - equalFilePath(command, item.second)) + for (const auto& [description, cmd] : defaultCommands_) + if (newCommand == utfTo<Zstring>(description) || + equalNoCase(newCommand, cmd)) return; - erase_if(history_, [&](const Zstring& item) { return equalFilePath(command, item); }); + erase_if(history_, [&](const Zstring& item) { return equalNoCase(newCommand, item); }); - history_.insert(history_.begin(), command); + history_.insert(history_.begin(), newCommand); if (history_.size() > historyMax_) history_.resize(historyMax_); @@ -104,8 +104,8 @@ void CommandBox::setValueAndUpdateList(const std::wstring& value) std::deque<std::wstring> items; //1. built in commands - for (const auto& item : defaultCommands_) - items.push_back(item.first); + for (const auto& [description, cmd] : defaultCommands_) + items.push_back(description); //2. history elements auto histSorted = history_; @@ -154,9 +154,9 @@ void CommandBox::OnValidateSelection(wxCommandEvent& event) if (value == getSeparationLine()) return setValueAndUpdateList(std::wstring()); - for (const auto& item : defaultCommands_) - if (item.first == value) - return setValueAndUpdateList(utfTo<std::wstring>(item.second)); //replace GUI name by actual command string + for (const auto& [description, cmd] : defaultCommands_) + if (description == value) + return setValueAndUpdateList(utfTo<std::wstring>(cmd)); //replace GUI name by actual command string } |