From 40ee047ef0cce230df2df8afb3a8f8c76e977ab3 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sat, 4 Jan 2025 16:46:18 -0500 Subject: [PATCH] Fix crash when pressing home key on empty tags field * Fixes #11344 --- src/gui/tag/TagsEdit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/tag/TagsEdit.cpp b/src/gui/tag/TagsEdit.cpp index 6bd0d39dfa..883c7b1234 100644 --- a/src/gui/tag/TagsEdit.cpp +++ b/src/gui/tag/TagsEdit.cpp @@ -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;