| 578 | } |
| 579 | |
| 580 | void 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 | |
| 620 | void InlineChatWidgetPrivate::updateButtonIcon() |
| 621 | { |
nothing calls this directly
no test coverage detected