diff --git a/src/plugins/duieditor/duieditor.cpp b/src/plugins/duieditor/duieditor.cpp
index 9300ba45f3664339e5a8ff0d46520122c32776ab..58624f55617452a855bab03eb84770c64760e3e4 100644
--- a/src/plugins/duieditor/duieditor.cpp
+++ b/src/plugins/duieditor/duieditor.cpp
@@ -617,8 +617,10 @@ void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedCha
 {
 	TextEditor::TabSettings ts = tabSettings();
 
-	if (typedChar == QLatin1Char('}')) {
-		QTextCursor tc = textCursor();
+	if (typedChar == QLatin1Char('}')
+		|| ((typedChar == QChar::Null) && block.text().trimmed() == "}")) {
+
+		QTextCursor tc(block);
 		if (TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tc)) {
 			const QString text = tc.block().text();
 			int indent = ts.columnAt(text, ts.firstNonSpace(text));