Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
7d936a39
Commit
7d936a39
authored
May 06, 2009
by
mae
Browse files
make insertion of braces a bit faster, by saving some of the rehighlighting work
parent
b82673c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cpphighlighter.cpp
View file @
7d936a39
...
...
@@ -58,6 +58,7 @@ void CppHighlighter::highlightBlock(const QString &text)
braceDepth
=
previousState
>>
8
;
}
SimpleLexer
tokenize
;
tokenize
.
setQtMocRunEnabled
(
false
);
...
...
@@ -210,6 +211,28 @@ void CppHighlighter::highlightBlock(const QString &text)
TextEditDocumentLayout
::
setParentheses
(
currentBlock
(),
parentheses
);
// optimization: if only the brace depth changes, we adjust subsequent blocks
// to have QSyntaxHighlighter stop the rehighlighting
int
currentState
=
currentBlockState
();
if
(
currentState
!=
-
1
)
{
int
oldState
=
currentState
&
0xff
;
int
oldBraceDepth
=
currentState
>>
8
;
if
(
oldState
==
tokenize
.
state
()
&&
oldBraceDepth
!=
braceDepth
)
{
int
delta
=
braceDepth
-
oldBraceDepth
;
QTextBlock
block
=
currentBlock
().
next
();
while
(
block
.
isValid
())
{
currentState
=
block
.
userState
();
if
(
currentState
!=
-
1
)
{
oldState
=
currentState
&
0xff
;
oldBraceDepth
=
currentState
>>
8
;
block
.
setUserState
(
qMax
(
0
,
(
oldBraceDepth
+
delta
)
<<
8
)
|
oldState
);
}
block
=
block
.
next
();
}
}
}
setCurrentBlockState
((
braceDepth
<<
8
)
|
tokenize
.
state
());
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment