From 8622327d9e9e6e2b3c7d609cf5b6f6d2d3296d54 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Tue, 26 Nov 2024 18:03:35 -0800 Subject: [PATCH] python: Fix paste indentation. --- src/plugins/python/pythonindenter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/python/pythonindenter.cpp b/src/plugins/python/pythonindenter.cpp index b907d0f4531..b9d2bbbd9c7 100644 --- a/src/plugins/python/pythonindenter.cpp +++ b/src/plugins/python/pythonindenter.cpp @@ -64,6 +64,10 @@ int PythonIndenter::indentFor(const QTextBlock &block, if (!previousBlock.isValid()) return 0; + // OPENMV-DIFF // + int previousIndentation = tabSettings.indentationColumn(previousBlock.text()); + // OPENMV-DIFF // + // When pasting in actual code, try to skip back past empty lines to an // actual code line to find a suitable indentation. This prevents code from // not being indented when pasting below an empty line. @@ -81,6 +85,11 @@ int PythonIndenter::indentFor(const QTextBlock &block, else indentation = qMax(0, indentation + getIndentDiff(previousLine, tabSettings)); + // OPENMV-DIFF // + if (previousIndentation < indentation) + indentation = previousIndentation; + // OPENMV-DIFF // + return indentation; }