Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where pressing home on empty tag field crashes the program. #11346

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/gui/tag/TagsEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ struct TagsEdit::Impl
assert(i < tags.size());
auto occurrencesOfCurrentText =
std::count_if(tags.cbegin(), tags.cend(), [this](const auto& tag) { return tag.text == currentText(); });
if (currentText().isEmpty() || occurrencesOfCurrentText > 1) {
if ((currentText().isEmpty() && tags.size() > 1) || occurrencesOfCurrentText > 1) {
tags.erase(std::next(tags.begin(), std::ptrdiff_t(editing_index)));
libklein marked this conversation as resolved.
Show resolved Hide resolved
if (editing_index <= i) { // Do we shift positions after `i`?
--i;
Expand Down