forked from qt-creator/qt-creator
TextEditor: improve performance of painting indent depth
Avoid asking the indenter for the visual indent depth since some implementations are not cheap and might even cause file io. Fall back to the default detection. Change-Id: Ic85d134fc29a0599768ac05c306b8593e83db327 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
@@ -4539,12 +4539,7 @@ int TextEditorWidgetPrivate::indentDepthForBlock(const QTextBlock &block, const
|
|||||||
m_visualIndentCache.resize(size, -1);
|
m_visualIndentCache.resize(size, -1);
|
||||||
};
|
};
|
||||||
int depth = blockDepth(block);
|
int depth = blockDepth(block);
|
||||||
if (depth < 0) // the block was empty and uncached ask the indenter for a visual indentation
|
if (depth < 0) {
|
||||||
depth = m_document->indenter()->visualIndentFor(block, data.tabSettings);
|
|
||||||
if (depth >= 0) {
|
|
||||||
ensureCacheSize(block.blockNumber() + 1);
|
|
||||||
m_visualIndentCache[block.blockNumber()] = depth;
|
|
||||||
} else {
|
|
||||||
// find previous non empty block and get the indent depth of this block
|
// find previous non empty block and get the indent depth of this block
|
||||||
QTextBlock it = block.previous();
|
QTextBlock it = block.previous();
|
||||||
int prevDepth = -1;
|
int prevDepth = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user