From e70b99c7da49c27b519f2fcacb4e06974ef1f6ad Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 12 Jan 2024 15:11:53 +0100 Subject: [PATCH] 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 --- src/plugins/texteditor/textindenter.cpp | 9 +++++++++ src/plugins/texteditor/textindenter.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/texteditor/textindenter.cpp b/src/plugins/texteditor/textindenter.cpp index 5684bcfc092..8ffbca4534d 100644 --- a/src/plugins/texteditor/textindenter.cpp +++ b/src/plugins/texteditor/textindenter.cpp @@ -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 &blocks, const TabSettings &tabSettings, int /*cursorPositionInEditor*/) diff --git a/src/plugins/texteditor/textindenter.h b/src/plugins/texteditor/textindenter.h index 98bf56c54d5..7198fbbc6fc 100644 --- a/src/plugins/texteditor/textindenter.h +++ b/src/plugins/texteditor/textindenter.h @@ -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 &blocks, const TabSettings &tabSettings, int cursorPositionInEditor = -1) override;