diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-01-03 15:32:28 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-01-04 10:23:47 +0100 |
commit | a7e5f80d70a8636b1b54b23123017f65fca1fc83 (patch) | |
tree | fe8ace0850f15ca2b9366983d20a1cf14011b059 /src/libs/qmljs/qmljscodeformatter.cpp | |
parent | 465f02a5b363b47b132f7ddf128456dac49e4c6c (diff) | |
download | qt-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/libs/qmljs/qmljscodeformatter.cpp')
-rw-r--r-- | src/libs/qmljs/qmljscodeformatter.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp index 5fb4a9ebcf..6914bb10e7 100644 --- a/src/libs/qmljs/qmljscodeformatter.cpp +++ b/src/libs/qmljs/qmljscodeformatter.cpp @@ -471,6 +471,18 @@ int CodeFormatter::indentFor(const QTextBlock &block) return m_indentDepth; } +int CodeFormatter::indentForNewLineAfter(const QTextBlock &block) +{ + restoreCurrentState(block); + + int lexerState = loadLexerState(block); + m_tokens.clear(); + m_currentLine.clear(); + adjustIndent(m_tokens, lexerState, &m_indentDepth); + + return m_indentDepth; +} + void CodeFormatter::updateStateUntil(const QTextBlock &endBlock) { QStack<State> previousState = initialState(); |