QmlJS: Fix folding information for multi-line comments after edits.

Since the highlighter doesn't run on the whole file, only on the changed
line, we need to store the information whether a block starts in a
multi-line comment.

Reviewed-by: Erik Verbruggen
This commit is contained in:
Christian Kamm
2010-05-27 14:46:30 +02:00
parent 381c54063c
commit 68cec6a7c7

View File

@@ -309,6 +309,7 @@ int Highlighter::onBlockStart()
m_currentBlockParentheses.clear();
m_braceDepth = 0;
m_foldingIndent = 0;
m_inMultilineComment = false;
if (TextEditor::TextBlockUserData *userData = TextEditor::BaseTextDocumentLayout::testUserData(currentBlock())) {
userData->setFoldingIndent(0);
userData->setFoldingStartIncluded(false);
@@ -319,7 +320,8 @@ int Highlighter::onBlockStart()
int previousState = previousBlockState();
if (previousState != -1) {
state = previousState & 0xff;
m_braceDepth = previousState >> 8;
m_inMultilineComment = (previousState >> 8) & 0xff;
m_braceDepth = previousState >> 16;
}
m_foldingIndent = m_braceDepth;
@@ -330,7 +332,7 @@ void Highlighter::onBlockEnd(int state)
{
typedef TextEditor::TextBlockUserData TextEditorBlockData;
setCurrentBlockState((m_braceDepth << 8) | state);
setCurrentBlockState((m_braceDepth << 16) | (m_inMultilineComment << 8) | state);
TextEditor::BaseTextDocumentLayout::setParentheses(currentBlock(), m_currentBlockParentheses);
TextEditor::BaseTextDocumentLayout::setFoldingIndent(currentBlock(), m_foldingIndent);
}