Skip to content

Commit

Permalink
fix: [completion] Fixed an issue where the cursor position was abnorm…
Browse files Browse the repository at this point in the history
…al when completion was canceled

as title

Log: fix issue
  • Loading branch information
Kakueeen committed Oct 23, 2024
1 parent 7d84faa commit 2dc4a09
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/plugins/binarytools/configure/default_binarytools.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"channelData": "%{CurrentDocument:Content}",
"triggerEvent" : 0
}
}
}
]
}
],
Expand All @@ -192,6 +192,6 @@
"hunspell",
"clang-format"
]
}
}
]
}
15 changes: 12 additions & 3 deletions src/plugins/codeeditor/gui/private/texteditor_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,19 @@ void TextEditorPrivate::cancelInlineCompletion()
if (inlineCompletionCache.first == -1)
return;

q->clearEOLAnnotations(inlineCompletionCache.first);
q->clearAnnotations(inlineCompletionCache.first);
auto cancelFunc = [this] {
if (leftButtonPressed)
return cancelInlineCompletion();

inlineCompletionCache = qMakePair(-1, QString());
q->clearEOLAnnotations(inlineCompletionCache.first);
q->clearAnnotations(inlineCompletionCache.first);
inlineCompletionCache = qMakePair(-1, QString());
};

if (leftButtonPressed)
QTimer::singleShot(50, this, cancelFunc);
else
cancelFunc();
}

void TextEditorPrivate::updateInlineCompletion()
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/codegeex/codegeex/codegeexcompletionprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ QString CodeGeeXCompletionProvider::providerName() const

void CodeGeeXCompletionProvider::provideInlineCompletionItems(const Position &pos, const InlineCompletionContext &c)
{
for (const auto &item : qAsConst(completionItems)) {
if (c.prefix.endsWith(item.completion))
return;
}

positon = pos;
context = c;
connect(&timer, &QTimer::timeout, Copilot::instance(), &Copilot::generateCode, Qt::UniqueConnection);
Expand Down

0 comments on commit 2dc4a09

Please sign in to comment.