SideBySideDiffEditor: Move showing diff into separate thread

Change-Id: I8b0a4835cf6f51e4acfd483dcfc7b94585c64bf5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-09-28 11:32:13 +02:00
parent 83be3443de
commit 53fc68bc08
3 changed files with 134 additions and 28 deletions

View File

@@ -124,11 +124,11 @@ void UnifiedDiffEditorWidget::setFontSettings(const FontSettings &fontSettings)
void UnifiedDiffEditorWidget::slotCursorPositionChangedInEditor()
{
const int fileIndex = fileIndexForBlockNumber(textCursor().blockNumber());
if (fileIndex < 0)
if (m_controller.m_ignoreChanges.isLocked())
return;
if (m_controller.m_ignoreChanges.isLocked())
const int fileIndex = fileIndexForBlockNumber(textCursor().blockNumber());
if (fileIndex < 0)
return;
const GuardLocker locker(m_controller.m_ignoreChanges);
@@ -515,7 +515,7 @@ void UnifiedDiffEditorWidget::showDiff()
const DiffEditorInput input(&m_controller);
auto getDocument = [=](QFutureInterface<ShowResult> &futureInterface) {
auto getDocument = [input](QFutureInterface<ShowResult> &futureInterface) {
auto cleanup = qScopeGuard([&futureInterface] {
if (futureInterface.isCanceled())
futureInterface.reportCanceled();
@@ -540,7 +540,7 @@ void UnifiedDiffEditorWidget::showDiff()
// but this would freeze the thread for couple of seconds without progress reporting
// and without checking for canceled.
const int diffSize = output.diffText.size();
const int packageSize = 100000;
const int packageSize = 10000;
int currentPos = 0;
QTextCursor cursor(result.textDocument->document());
while (currentPos < diffSize) {