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 17dc022e15
commit 40ee047ef0

View File

@ -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 (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;