Fix crash when pressing home key on empty tags field

* Fixes #11344
This commit is contained in:
Jonathan White
2025-01-04 16:46:18 -05:00
parent 09e47d3731
commit ef2b5e7c26

View File

@@ -343,7 +343,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 (tags.size() > 1 && (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;