Skip to content

Commit

Permalink
fix: code generation display issue
Browse files Browse the repository at this point in the history
Log:
Change-Id: I23c64bf94e4a2546fb9c1f1ef381500e677725eb
  • Loading branch information
deepin-mozart authored and deepin-ci-robot committed Dec 12, 2023
1 parent 4a66b66 commit 587c01a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plugins/codegeex/copilot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Copilot::Copilot(QObject *parent)
case CopilotApi::multilingual_code_generate:
mutexResponse.lock();
generateResponse = response;
if (editorService->showTips && !response.isEmpty()) {
if (editorService->showTips && responseValid(response)) {
editorService->showTips(generateResponse);
}
mutexResponse.unlock();
Expand Down Expand Up @@ -76,6 +76,11 @@ QString Copilot::apiKey() const
return {};
}

bool Copilot::responseValid(const QString &response)
{
return !(response.isEmpty() || response.startsWith("\n\n\n") || response.startsWith("\n "));
}

Copilot *Copilot::instance()
{
static Copilot ins;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/codegeex/copilot.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public slots:
explicit Copilot(QObject *parent = nullptr);
QString selectedText() const;
QString apiKey() const;
bool responseValid(const QString &response);

CodeGeeX::CopilotApi copilotApi;
dpfservice::EditorService *editorService = nullptr;
Expand Down

0 comments on commit 587c01a

Please sign in to comment.