From ef2b5e7c2618a2fedb3d5bfae22ccad10c93f695 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 4388f4790..10afae1f8 100644 --- a/src/gui/tag/TagsEdit.cpp +++ b/src/gui/tag/TagsEdit.cpp @@ -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;