Editor: improve visual indent depth for empty blocks

Use the indenter based visual indent only for the cpp qt style indenter
since it gives accurate results. In all other casess Look for the next
and previous not empty lines and use the minimum indent depth of those
lines as the visual indent depth for empty lines.

Task-number: QTCREATORBUG-28179
Change-Id: Ic456fba5adfb2a12f20e2bd4fc663010c752b65c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2022-10-05 13:48:16 +02:00
parent f513820be0
commit bf5a8835ee
6 changed files with 85 additions and 12 deletions

View File

@@ -67,6 +67,11 @@ int Indenter::indentFor(const QTextBlock &block,
return codeFormatter.indentFor(block);
}
int Indenter::visualIndentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings)
{
return indentFor(block, tabSettings);
}
TextEditor::IndentationForBlock Indenter::indentationForBlocks(
const QVector<QTextBlock> &blocks,
const TextEditor::TabSettings &tabSettings,

View File

@@ -26,6 +26,8 @@ public:
int indentFor(const QTextBlock &block,
const TextEditor::TabSettings &tabSettings,
int cursorPositionInEditor = -1) override;
int visualIndentFor(const QTextBlock &block,
const TextEditor::TabSettings &tabSettings) override;
TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,
const TextEditor::TabSettings &tabSettings,
int cursorPositionInEditor = -1) override;