Skip to content

Commit

Permalink
Fix crash when pressing home key on empty tags field
Browse files Browse the repository at this point in the history
* Fixes #11344
  • Loading branch information
droidmonkey committed Jan 4, 2025
1 parent 620abb9 commit 4a187dd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gui/tag/TagsEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ struct TagsEdit::Impl
auto occurrencesOfCurrentText =
std::count_if(tags.cbegin(), tags.cend(), [this](const auto& tag) { return tag.text == currentText(); });
if (currentText().isEmpty() || occurrencesOfCurrentText > 1) {
tags.erase(std::next(tags.begin(), std::ptrdiff_t(editing_index)));
if (editing_index <= i) { // Do we shift positions after `i`?
--i;
if (tags.size() > 1) {
tags.erase(std::next(tags.begin(), std::ptrdiff_t(editing_index)));
if (editing_index <= i) { // Do we shift positions after `i`?
--i;
}
}
}
editing_index = i;
Expand Down

0 comments on commit 4a187dd

Please sign in to comment.