From 4481686909d8e23bc0a4d077a379ebaceba8ffa0 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 12 Jun 2023 09:25:22 +0200 Subject: [PATCH] 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: Reviewed-by: Christian Stenger Reviewed-by: Artem Sokolovskii --- src/plugins/texteditor/texteditor.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 0a0e1dff889..e7f428f83b6 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -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;