Skip to content

Commit

Permalink
speed-up linewrap calculation when loading large documents
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Nov 6, 2023
1 parent 077192f commit 1376e43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/qcodeedit/lib/document/qdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7230,7 +7230,7 @@ void QDocumentPrivate::setWidth()

// static const int widthCacheSize = 5; // unused ...

void QDocumentPrivate::adjustWidth(int line)
void QDocumentPrivate::adjustWidth(int line, bool multiLine)
{
if ( line < 0 || line >= m_lines.count() )
return;
Expand All @@ -7257,9 +7257,10 @@ void QDocumentPrivate::adjustWidth(int line)
//qDebug("removed wrap on line %i", line);
m_wrapped.remove(line);
}

emitFormatsChange(line, -1);
setHeight();
if(!multiLine){
emitFormatsChange(line, -1);
setHeight();
}
}
}
if ( !m_constrained ) {
Expand Down Expand Up @@ -8493,7 +8494,7 @@ void QDocumentPrivate::emitContentsChange(int line, int lines)
}

for (int i=line; i<line+lines; i++)
adjustWidth(i);
adjustWidth(i,true);
if (lines > 1) setHeight();
//qDebug("%i, %i : %i", line, lines, n);

Expand Down
2 changes: 1 addition & 1 deletion src/qcodeedit/lib/document/qdocument_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class QCE_EXPORT QDocumentPrivate
QDocumentLineHandle* next(const QDocumentLineHandle *l) const;
QDocumentLineHandle* previous(const QDocumentLineHandle *l) const;

void adjustWidth(int l);
void adjustWidth(int l,bool multiLine=false);
//int checkWidth(QDocumentLineHandle *l, int w);
//int checkWidth(QDocumentLineHandle *l, const QString& s);

Expand Down

0 comments on commit 1376e43

Please sign in to comment.