mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08: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:
parent
57a6a0d9cb
commit
5d06bb903d
1 changed files with 9 additions and 0 deletions
|
|
@ -130,10 +130,19 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event)
|
||||||
CompleterInfo *active = nullptr;
|
CompleterInfo *active = nullptr;
|
||||||
QString prefix;
|
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) {
|
for (auto &info : completers) {
|
||||||
bool triggered = false;
|
bool triggered = false;
|
||||||
switch (info.trigger) {
|
switch (info.trigger) {
|
||||||
case CompleterTrigger::Mention: {
|
case CompleterTrigger::Mention: {
|
||||||
|
if (insideCardLink) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
int triggerPos = textValue.lastIndexOf("@", cursorPos - 1);
|
int triggerPos = textValue.lastIndexOf("@", cursorPos - 1);
|
||||||
if (triggerPos != -1 && (triggerPos == 0 || textValue[triggerPos - 1].isSpace())) {
|
if (triggerPos != -1 && (triggerPos == 0 || textValue[triggerPos - 1].isSpace())) {
|
||||||
triggered = true;
|
triggered = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue