summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp1
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp5
-rw-r--r--src/plugins/cpptools/cppcodeformatter.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 226b27a861..a2d766effc 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1539,6 +1539,7 @@ void CPPEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedCha
codeFormatter.setIndentDeclarationMembers(true);
}
+ codeFormatter.updateStateUntil(block);
const int depth = codeFormatter.indentFor(block);
ts.indentLine(block, depth);
}
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 97db194e70..0eb40bf4e9 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -446,12 +446,12 @@ int CodeFormatter::indentFor(const QTextBlock &block)
{
// qDebug() << "indenting for" << block.blockNumber() + 1;
- requireStatesUntil(block);
+ restoreBlockState(block.previous());
correctIndentation(block);
return m_indentDepth;
}
-void CodeFormatter::requireStatesUntil(const QTextBlock &endBlock)
+void CodeFormatter::updateStateUntil(const QTextBlock &endBlock)
{
QStack<State> previousState = initialState();
QTextBlock it = endBlock.document()->firstBlock();
@@ -473,7 +473,6 @@ void CodeFormatter::requireStatesUntil(const QTextBlock &endBlock)
//qDebug() << "recalc line" << it.blockNumber() + 1;
recalculateStateAfter(it);
}
- restoreBlockState(endBlock.previous());
}
CodeFormatter::State CodeFormatter::state(int belowTop) const
diff --git a/src/plugins/cpptools/cppcodeformatter.h b/src/plugins/cpptools/cppcodeformatter.h
index 16375892af..2475603d4d 100644
--- a/src/plugins/cpptools/cppcodeformatter.h
+++ b/src/plugins/cpptools/cppcodeformatter.h
@@ -28,6 +28,7 @@ public:
CodeFormatter();
virtual ~CodeFormatter();
+ void updateStateUntil(const QTextBlock &block);
int indentFor(const QTextBlock &block);
void setTabSize(int tabSize);
@@ -138,7 +139,6 @@ protected:
bool isBracelessState(int type) const;
private:
- void requireStatesUntil(const QTextBlock &block);
void recalculateStateAfter(const QTextBlock &block);
void storeBlockState(const QTextBlock &block);
void restoreBlockState(const QTextBlock &block);