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:
David Schulz
2023-06-12 09:25:22 +02:00
parent e24be95601
commit 4481686909

View File

@@ -4539,12 +4539,7 @@ int TextEditorWidgetPrivate::indentDepthForBlock(const QTextBlock &block, const
m_visualIndentCache.resize(size, -1);
};
int depth = blockDepth(block);
if (depth < 0) // the block was empty and uncached ask the indenter for a visual indentation
depth = m_document->indenter()->visualIndentFor(block, data.tabSettings);
if (depth >= 0) {
ensureCacheSize(block.blockNumber() + 1);
m_visualIndentCache[block.blockNumber()] = depth;
} else {
if (depth < 0) {
// find previous non empty block and get the indent depth of this block
QTextBlock it = block.previous();
int prevDepth = -1;