From 5d06bb903d8016b495d4be2d0d149b3f965ccb77 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Sun, 11 Oct 2026 15:35:10 +0200 Subject: [PATCH] [Chat] Fix card completion after an @ mention (#7469) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An open [[ card link now takes precedence over a space-preceded @ mention, so typing an @ before a card no longer shadows the card completer. Co-authored-by: Lukas BrĂ¼bach --- .../interface/widgets/utility/line_edit_completer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp b/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp index 056887f1a..d692fb41b 100644 --- a/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp +++ b/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp @@ -130,10 +130,19 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event) CompleterInfo *active = nullptr; QString prefix; + // An open "[[" card link takes precedence over a mention: while the cursor is + // inside it, an earlier "@" must not shadow the card completer. + const int openCardPos = textValue.lastIndexOf("[[", cursorPos - 1); + const int closeCardPos = openCardPos == -1 ? -1 : textValue.indexOf("]]", openCardPos + 2); + const bool insideCardLink = openCardPos != -1 && (closeCardPos == -1 || closeCardPos >= cursorPos); + for (auto &info : completers) { bool triggered = false; switch (info.trigger) { case CompleterTrigger::Mention: { + if (insideCardLink) { + break; + } int triggerPos = textValue.lastIndexOf("@", cursorPos - 1); if (triggerPos != -1 && (triggerPos == 0 || textValue[triggerPos - 1].isSpace())) { triggered = true;