TextEditor: avoid autoIndent when using default TextIndenter

Most programming languages use indentation to group stuff. So if we have
no special language support for a text file it is useful to start a
newline on the same indent depth as the previous line. But if we trigger
an explicit reindent (default ctrl+i) we usually don't want to change
the indentation if we don't know exactly where it should end up. This
also applies to refactoring changes, for example from the lsp.

Change-Id: I8268dc88cbceddfc7112757fd7d2fef940ab9a39
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
David Schulz
2024-01-12 15:11:53 +01:00
parent 0db551bfe7
commit e70b99c7da
2 changed files with 13 additions and 0 deletions

View File

@@ -51,6 +51,15 @@ int TextIndenter::indentFor(const QTextBlock &block,
return tabSettings.indentationColumn(previousText);
}
void TextIndenter::autoIndent(const QTextCursor &cursor,
const TabSettings &tabSettings,
int cursorPositionInEditor)
{
Q_UNUSED(cursor);
Q_UNUSED(tabSettings);
Q_UNUSED(cursorPositionInEditor);
}
IndentationForBlock TextIndenter::indentationForBlocks(const QVector<QTextBlock> &blocks,
const TabSettings &tabSettings,
int /*cursorPositionInEditor*/)

View File

@@ -26,6 +26,10 @@ public:
const TabSettings &tabSettings,
int cursorPositionInEditor = -1) override;
void autoIndent(const QTextCursor &cursor,
const TabSettings &tabSettings,
int cursorPositionInEditor = -1) override;
IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,
const TabSettings &tabSettings,
int cursorPositionInEditor = -1) override;