Skip to content
Snippets Groups Projects
Commit 1f525f92 authored by Kai Koehne's avatar Kai Koehne
Browse files

Fix auto-indentation for dui editor

This patch should fix auto-indentation (Ctrl+I) for the most usual
cases. Before this patch, lines were never dedented, resulting in e.g.

Rect {
  Item {
    }
    Item {
      }
parent 05b474ab
No related branches found
No related tags found
No related merge requests found
...@@ -617,8 +617,10 @@ void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedCha ...@@ -617,8 +617,10 @@ void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedCha
{ {
TextEditor::TabSettings ts = tabSettings(); TextEditor::TabSettings ts = tabSettings();
if (typedChar == QLatin1Char('}')) { if (typedChar == QLatin1Char('}')
QTextCursor tc = textCursor(); || ((typedChar == QChar::Null) && block.text().trimmed() == "}")) {
QTextCursor tc(block);
if (TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tc)) { if (TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tc)) {
const QString text = tc.block().text(); const QString text = tc.block().text();
int indent = ts.columnAt(text, ts.firstNonSpace(text)); int indent = ts.columnAt(text, ts.firstNonSpace(text));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment