Skip to content

Commit 8e61351

Browse files
Kakueeendeepin-mozart
authored andcommitted
fix: [inline chat] No result was returned for a long time
Network request error, but no error handling Log: fix bug Bug: https://pms.uniontech.com/bug-view-281817.html
1 parent da01f7b commit 8e61351

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/plugins/codeeditor/gui/private/texteditor_p.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void TextEditorPrivate::initMargins()
113113
void TextEditorPrivate::initWidgetContainer()
114114
{
115115
lineWidgetContainer = new DFloatingWidget(q);
116-
lineWidgetContainer->setFramRadius(6);
116+
lineWidgetContainer->setFramRadius(18);
117117
lineWidgetContainer->setVisible(false);
118118
QHBoxLayout *layout = new QHBoxLayout(lineWidgetContainer);
119119
layout->setContentsMargins(0, 0, 0, 0);

src/plugins/codeeditor/gui/texteditor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ void TextEditor::replaceRange(int lineFrom, int indexFrom, int lineTo, int index
659659

660660
void TextEditor::replaceRange(int startPosition, int endPosition, const QString &text)
661661
{
662+
SendScintilla(SCI_CLEARSELECTIONS);
662663
SendScintilla(SCI_SETTARGETSTART, startPosition);
663664
SendScintilla(SCI_SETTARGETEND, endPosition);
664665
SendScintilla(SCI_REPLACETARGET, -1, textAsBytes(text).constData());

src/plugins/codegeex/codegeex/copilotapi.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,25 @@ void CopilotApi::processResponse(QNetworkReply *reply)
248248

249249
void CopilotApi::slotReadReply(QNetworkReply *reply)
250250
{
251-
if (reply->error()) {
252-
qCritical() << "Error:" << reply->errorString();
251+
if (reply->error() != QNetworkReply::NoError) {
252+
qCritical() << "Error:" << reply->errorString() << reply->error();
253+
if (reply->error() != QNetworkReply::OperationCanceledError) {
254+
auto type = reply->property("responseType").value<CopilotApi::ResponseType>();
255+
emit response(type, "", "");
256+
}
253257
} else {
254258
QString replyMsg = QString::fromUtf8(reply->readAll());
255259
QJsonParseError error;
256260
QJsonDocument jsonDocument = QJsonDocument::fromJson(replyMsg.toUtf8(), &error);
257-
261+
auto type = reply->property("responseType").value<CopilotApi::ResponseType>();
258262
if (error.error != QJsonParseError::NoError) {
259263
qCritical() << "JSON parse error: " << error.errorString();
264+
emit response(type, "", "");
260265
return;
261266
}
262267

263268
QJsonObject jsonObject = jsonDocument.object();
264269
QString code {};
265-
266-
auto type = reply->property("responseType").value<CopilotApi::ResponseType>();
267270
if (type == CopilotApi::inline_completions) {
268271
auto content = jsonObject.value("inline_completions").toArray().at(0).toObject();
269272
code = content.value("text").toString();

src/plugins/codegeex/widgets/inlinechatwidget.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,10 @@ void InlineChatWidgetPrivate::handleClose()
482482

483483
void InlineChatWidgetPrivate::handleStop()
484484
{
485-
setState(prevState);
485+
setState(Original);
486486
edit->setPlainText(questionLabel->text());
487487
edit->moveCursor(QTextCursor::End);
488+
questionLabel->clear();
488489
foreach (auto watcher, futureWatcherList) {
489490
if (!watcher->isFinished())
490491
watcher->cancel();
@@ -549,6 +550,7 @@ bool InlineChatWidgetPrivate::askForCodeGeeX()
549550

550551
QSignalBlocker blk(edit);
551552
edit->clear();
553+
edit->onTextChanged();
552554
questionLabel->setEnabled(true);
553555
answerLabel->setEnabled(true);
554556
questionLabel->setText(question);

0 commit comments

Comments
 (0)