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
This commit is contained in:
Christian Kamm
2011-01-03 15:32:28 +01:00
parent 465f02a5b3
commit a7e5f80d70
3 changed files with 22 additions and 1 deletions

View File

@@ -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();

View File

@@ -66,6 +66,7 @@ public:
void updateLineStateChange(const QTextBlock &block);
int indentFor(const QTextBlock &block);
int indentForNewLineAfter(const QTextBlock &block);
void setTabSize(int tabSize);