MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / processGeneratedData

Method processGeneratedData

src/plugins/chat/widgets/inlinechatwidget.cpp:580–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578}
579
580void InlineChatWidgetPrivate::processGeneratedData(const QString &data)
581{
582 editSrv->clearAllBackgroundColor(chatInfo.fileName, selectionMarker);
583 chatInfo.operationRange.clear();
584 chatInfo.diffList.clear();
585 chatInfo.destText = data;
586 if (chatInfo.originalText.isEmpty())
587 chatInfo.diffList << Diff { INSERT, data };
588 else
589 chatInfo.diffList = diffText(chatInfo.originalText, data);
590
591 int startLine = chatInfo.originalRange.start.line;
592 int endLine = 0;
593 QString tempText;
594 for (auto diff : chatInfo.diffList) {
595 if (!diff.text.endsWith('\n'))
596 diff.text.append('\n');
597
598 endLine = startLine + diff.text.count('\n') - 1;
599 if (diff.operation != EQUAL) {
600 Edit::Range range;
601 range.start.line = startLine;
602 range.end.line = endLine;
603 chatInfo.operationRange.insert(diff.operation, range);
604 }
605
606 startLine = endLine + 1;
607 tempText.append(diff.text);
608 }
609
610 chatInfo.tempText = tempText;
611 editSrv->replaceRange(chatInfo.fileName, chatInfo.originalRange, tempText);
612 auto iter = chatInfo.operationRange.cbegin();
613 for (; iter != chatInfo.operationRange.cend(); ++iter) {
614 const auto &range = iter.value();
615 iter.key() == DELETE ? editSrv->setRangeBackgroundColor(chatInfo.fileName, range.start.line, range.end.line, deleteMarker)
616 : editSrv->setRangeBackgroundColor(chatInfo.fileName, range.start.line, range.end.line, insertMarker);
617 }
618}
619
620void InlineChatWidgetPrivate::updateButtonIcon()
621{

Callers

nothing calls this directly

Calls 13

endsWithMethod · 0.80
insertMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
clearMethod · 0.45
isEmptyMethod · 0.45
appendMethod · 0.45
countMethod · 0.45
replaceRangeMethod · 0.45
valueMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected