aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cpphighlighter.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2014-01-23 22:16:43 +0200
committerOrgad Shaneh <orgads@gmail.com>2014-02-04 11:33:54 +0100
commite600424648eaebe5cf3ea1fa3ae8a41a22ce7b95 (patch)
treedc72db89fdf94ee00261c21338fe9ae3e0476f74 /src/plugins/cppeditor/cpphighlighter.cpp
parentfd31b4716cbc9c0be734163d599a22ac8a497b8a (diff)
C++: Fix support for incremental input with \n
Also fix false positive line continuation on blank line e.g. "foo \ bar" Change-Id: Ic6d345a4b578c955411d119b8438c8dc5065c072 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cppeditor/cpphighlighter.cpp')
-rw-r--r--src/plugins/cppeditor/cpphighlighter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp
index dec2b2f082..d039b9e147 100644
--- a/src/plugins/cppeditor/cpphighlighter.cpp
+++ b/src/plugins/cppeditor/cpphighlighter.cpp
@@ -66,7 +66,7 @@ CppHighlighter::CppHighlighter(QTextDocument *document) :
void CppHighlighter::highlightBlock(const QString &text)
{
const int previousState = previousBlockState();
- int state = T_EOF_SYMBOL, initialBraceDepth = 0;
+ int state = 0, initialBraceDepth = 0;
if (previousState != -1) {
state = previousState & 0xff;
initialBraceDepth = previousState >> 8;
@@ -85,6 +85,7 @@ void CppHighlighter::highlightBlock(const QString &text)
const QList<Token> tokens = tokenize(text, initialState);
state = tokenize.state(); // refresh the state
+ initialState &= ~0x80; // discard newline expected bit
int foldingIndent = initialBraceDepth;
if (TextBlockUserData *userData = BaseTextDocumentLayout::testUserData(currentBlock())) {
userData->setFoldingIndent(0);
@@ -93,7 +94,7 @@ void CppHighlighter::highlightBlock(const QString &text)
}
if (tokens.isEmpty()) {
- setCurrentBlockState(previousState);
+ setCurrentBlockState(state);
BaseTextDocumentLayout::clearParentheses(currentBlock());
if (text.length()) {// the empty line can still contain whitespace
if (initialState == T_COMMENT)