Skip to content

Commit

Permalink
python: Fix paste indentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwagyeman committed Nov 27, 2024
1 parent af6748b commit 8622327
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugins/python/pythonindenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -81,6 +85,11 @@ int PythonIndenter::indentFor(const QTextBlock &block,
else
indentation = qMax<int>(0, indentation + getIndentDiff(previousLine, tabSettings));

// OPENMV-DIFF //
if (previousIndentation < indentation)
indentation = previousIndentation;
// OPENMV-DIFF //

return indentation;
}

Expand Down

0 comments on commit 8622327

Please sign in to comment.