- enhancement: Reduce flicker when editing big files.

This commit is contained in:
Roy Qu 2023-02-18 07:09:19 +08:00
parent f4b239e15d
commit a91dc12519
4 changed files with 27 additions and 12 deletions

View File

@ -37,6 +37,7 @@ Red Panda C++ Version 2.12
- enhancement: Show "..." instead of "...}" when folding #if/#endif
- enhancement: Correctly handle high-precision mouse wheel / touchpad in editors.
- enhancement: Greatly reduce time to open/edit big files.
- enhancement: Reduce flicker when editing big files.
Red Panda C++ Version 2.11

View File

@ -1125,12 +1125,18 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
// qDebug()<<s;
// PStatement statement = mParser->findStatementOf(mFilename,
// s , p.Line);
QStringList expression = getExpressionAtPosition(p);
PStatement statement = parser()->findStatementOf(
filename(),
expression,
p.line);
StatementKind kind = getKindOfStatement(statement);
StatementKind kind;
if (mParser->parsing()){
kind=mIdentCache.value(QString("%1 %2").arg(aChar).arg(token),StatementKind::skUnknown);
} else {
QStringList expression = getExpressionAtPosition(p);
PStatement statement = parser()->findStatementOf(
filename(),
expression,
p.line);
kind = getKindOfStatement(statement);
mIdentCache.insert(QString("%1 %2").arg(aChar).arg(token),kind);
}
if (kind == StatementKind::skUnknown) {
QSynedit::BufferCoord pBeginPos,pEndPos;
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
@ -1356,7 +1362,7 @@ void Editor::showEvent(QShowEvent */*event*/)
connect(mParser.get(),
&CppParser::onEndParsing,
this,
&QSynedit::QSynEdit::invalidate);
&Editor::onEndParsing);
reparse(false);
}
if (mParentPageControl) {
@ -1399,7 +1405,7 @@ void Editor::hideEvent(QHideEvent */*event*/)
disconnect(mParser.get(),
&CppParser::onEndParsing,
this,
&QSynedit::QSynEdit::invalidate);
&Editor::onEndParsing);
}
pMainWindow->updateForEncodingInfo(nullptr);
pMainWindow->updateStatusbarForLineCol(nullptr);
@ -1973,6 +1979,12 @@ void Editor::onTooltipTimer()
}
}
void Editor::onEndParsing()
{
mIdentCache.clear();
invalidate();
}
void Editor::resolveAutoDetectEncodingOption()
{
if (mEncodingOption==ENCODING_AUTO_DETECT) {
@ -4341,7 +4353,7 @@ void Editor::setProject(Project *pProject)
connect(mParser.get(),
&CppParser::onEndParsing,
this,
&QSynedit::QSynEdit::invalidate);
&Editor::onEndParsing);
} else {
invalidate();
}

View File

@ -237,6 +237,7 @@ private slots:
void onFunctionTipsTimer();
void onAutoBackupTimer();
void onTooltipTimer();
void onEndParsing();
private:
void resolveAutoDetectEncodingOption();
@ -348,6 +349,7 @@ private:
QTimer mTooltipTimer;
int mHoverModifiedLine;
int mWheelAccumulatedDelta;
QMap<QString,StatementKind> mIdentCache;
static QHash<ParserLanguage,std::weak_ptr<CppParser>> mSharedParsers;

View File

@ -260,12 +260,12 @@ void Document::setContents(const QStringList &text)
QStringList Document::contents()
{
QMutexLocker locker(&mMutex);
QStringList Result;
QStringList result;
DocumentLines list = mLines;
foreach (const PDocumentLine& line, list) {
Result.append(line->lineText);
result.append(line->lineText);
}
return Result;
return result;
}
void Document::beginUpdate()