mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-10-27 01:50:08 -05:00
[Chat] Fix card completion after an @ mention (#7469)
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 <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user