diff --git a/NEWS.md b/NEWS.md index b2741da8..7abfd4ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ Red Panda C++ Version 3.2 - fix: Don't auto scroll to the caret after undo/redo. - fix: "bits/stdc++" is not openned in readonly mode. - fix: astyle path error when reformat. + - fix: Slow when paste/replace bulk contents. Red Panda C++ Version 3.1 diff --git a/libs/qsynedit/qsynedit/document.cpp b/libs/qsynedit/qsynedit/document.cpp index 9ebe2c47..f8e7f5b9 100644 --- a/libs/qsynedit/qsynedit/document.cpp +++ b/libs/qsynedit/qsynedit/document.cpp @@ -452,7 +452,8 @@ void Document::putLine(int index, const QString &s, bool notify) { if (index<0 || index>=mLines.count()) { listIndexOutOfBounds(index); } - beginUpdate(); + if (notify) + beginUpdate(); mLines[index]->setLineText(s); if (mIndexOfLongestLine == index) { // width is invalidated, so we must recalculate longest line @@ -460,7 +461,8 @@ void Document::putLine(int index, const QString &s, bool notify) { } if (notify) emit putted(index); - endUpdate(); + if (notify) + endUpdate(); } } diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 81e3746a..5cda9e4f 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -3246,12 +3246,15 @@ void QSynEdit::updateModifiedStatus() emit statusChanged(StatusChange::ModifyChanged); } -int QSynEdit::reparseLines(int startLine, int endLine) +int QSynEdit::reparseLines(int startLine, int endLine, bool needRescanFolds, bool toDocumentEnd) { SyntaxState state; + int maxLine = toDocumentEnd ? mDocument->count() : endLine+1; startLine = std::max(0,startLine); endLine = std::min(endLine, mDocument->count()); + maxLine = std::min(maxLine, mDocument->count()); + if (startLine >= endLine) return startLine; @@ -3271,7 +3274,7 @@ int QSynEdit::reparseLines(int startLine, int endLine) } mDocument->setSyntaxState(line,state); line++; - } while (line < mDocument->count()); + } while (line < maxLine); //don't rescan folds if only currentLine is reparsed if (line-startLine==1) @@ -3280,7 +3283,7 @@ int QSynEdit::reparseLines(int startLine, int endLine) if (mEditingCount>0) return line; - if (useCodeFolding()) + if (needRescanFolds && useCodeFolding()) rescanFolds(); return line; } @@ -5359,6 +5362,7 @@ int QSynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList QString sLeftSide; QString sRightSide; QString str; + QElapsedTimer timer; bool bChangeScroll; // int SpaceCount; int result = 0; @@ -5382,13 +5386,14 @@ int QSynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList str = sLeftSide + s; } else str = sLeftSide + text[0]; - properSetLine(caretY - 1, str); + properSetLine(caretY - 1, str, false); mDocument->insertLines(caretY, text.length()-1); } else { str = sLeftSide + text[0] + sRightSide; - properSetLine(caretY - 1, str); + properSetLine(caretY - 1, str, false); } - reparseLines(caretY-1,caretY); + reparseLines(caretY-1,caretY, false, false); + timer.start(); // step2: insert remaining lines of Value for (int i=1;i