summaryrefslogtreecommitdiff
path: root/src/plugins/qmljseditor
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-01-03 15:32:28 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-01-04 10:23:47 +0100
commita7e5f80d70a8636b1b54b23123017f65fca1fc83 (patch)
treefe8ace0850f15ca2b9366983d20a1cf14011b059 /src/plugins/qmljseditor
parent465f02a5b363b47b132f7ddf128456dac49e4c6c (diff)
downloadqt-creator-a7e5f80d70a8636b1b54b23123017f65fca1fc83.tar.gz
QmlJS indenter: Only auto-reindent if indent was unchanged.
This change in how electric characters are handled has gone into the C++ indenter a while ago and works well there. It means Creator is less likely to annoyingly change the indent on lines where the indentation whas changed manually. It is still possible to trigger a reindent manually. Reviewed-by: Erik Verbruggen
Diffstat (limited to 'src/plugins/qmljseditor')
-rw-r--r--src/plugins/qmljseditor/qmljsindenter.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/qmljseditor/qmljsindenter.cpp b/src/plugins/qmljseditor/qmljsindenter.cpp
index 99bd68a32e..8dddb7747f 100644
--- a/src/plugins/qmljseditor/qmljsindenter.cpp
+++ b/src/plugins/qmljseditor/qmljsindenter.cpp
@@ -66,7 +66,6 @@ void Indenter::indentBlock(QTextDocument *doc,
TextEditor::BaseTextEditor *editor)
{
Q_UNUSED(doc)
- Q_UNUSED(typedChar)
Q_UNUSED(editor)
const TextEditor::TabSettings &ts = editor->tabSettings();
@@ -74,5 +73,14 @@ void Indenter::indentBlock(QTextDocument *doc,
codeFormatter.updateStateUntil(block);
const int depth = codeFormatter.indentFor(block);
+
+ if (isElectricCharacter(typedChar)) {
+ // only reindent the current line when typing electric characters if the
+ // indent is the same it would be if the line were empty
+ const int newlineIndent = codeFormatter.indentForNewLineAfter(block.previous());
+ if (ts.indentationColumn(block.text()) != newlineIndent)
+ return;
+ }
+
ts.indentLine(block, depth);
}