forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.9' into 4.10
Change-Id: I7725557a279cc13fe03a72c20accf63b50571608
This commit is contained in:
@@ -274,9 +274,9 @@ void Highlighter::highlightBlock(const QString &text)
|
|||||||
{
|
{
|
||||||
if (!definition().isValid())
|
if (!definition().isValid())
|
||||||
return;
|
return;
|
||||||
const QTextBlock block = currentBlock();
|
QTextBlock block = currentBlock();
|
||||||
KSyntaxHighlighting::State state;
|
KSyntaxHighlighting::State state;
|
||||||
setCurrentBlockState(qMax(0, previousBlockState()));
|
TextDocumentLayout::setBraceDepth(block, TextDocumentLayout::braceDepth(block.previous()));
|
||||||
if (TextBlockUserData *data = TextDocumentLayout::testUserData(block)) {
|
if (TextBlockUserData *data = TextDocumentLayout::testUserData(block)) {
|
||||||
state = data->syntaxState();
|
state = data->syntaxState();
|
||||||
data->setFoldingStartIncluded(false);
|
data->setFoldingStartIncluded(false);
|
||||||
@@ -298,8 +298,11 @@ void Highlighter::highlightBlock(const QString &text)
|
|||||||
|
|
||||||
if (nextBlock.isValid()) {
|
if (nextBlock.isValid()) {
|
||||||
TextBlockUserData *data = TextDocumentLayout::userData(nextBlock);
|
TextBlockUserData *data = TextDocumentLayout::userData(nextBlock);
|
||||||
data->setSyntaxState(state);
|
if (data->syntaxState() != state) {
|
||||||
data->setFoldingIndent(currentBlockState());
|
data->setSyntaxState(state);
|
||||||
|
setCurrentBlockState(currentBlockState() ^ 1); // force rehighlight of next block
|
||||||
|
}
|
||||||
|
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
formatSpaces(text);
|
formatSpaces(text);
|
||||||
@@ -316,24 +319,24 @@ void Highlighter::applyFolding(int offset,
|
|||||||
{
|
{
|
||||||
if (!region.isValid())
|
if (!region.isValid())
|
||||||
return;
|
return;
|
||||||
const QTextBlock &block = currentBlock();
|
QTextBlock block = currentBlock();
|
||||||
const QString &text = block.text();
|
const QString &text = block.text();
|
||||||
TextBlockUserData *data = TextDocumentLayout::userData(currentBlock());
|
TextBlockUserData *data = TextDocumentLayout::userData(currentBlock());
|
||||||
const bool fromStart = TabSettings::firstNonSpace(text) == offset;
|
const bool fromStart = TabSettings::firstNonSpace(text) == offset;
|
||||||
const bool toEnd = (offset + length) == (text.length() - TabSettings::trailingWhitespaces(text));
|
const bool toEnd = (offset + length) == (text.length() - TabSettings::trailingWhitespaces(text));
|
||||||
if (region.type() == KSyntaxHighlighting::FoldingRegion::Begin) {
|
if (region.type() == KSyntaxHighlighting::FoldingRegion::Begin) {
|
||||||
setCurrentBlockState(currentBlockState() + 1);
|
TextDocumentLayout::changeBraceDepth(block, 1);
|
||||||
// if there is only a folding begin in the line move the current block into the fold
|
// if there is only a folding begin in the line move the current block into the fold
|
||||||
if (fromStart && toEnd) {
|
if (fromStart && toEnd) {
|
||||||
data->setFoldingIndent(currentBlockState());
|
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
|
||||||
data->setFoldingStartIncluded(true);
|
data->setFoldingStartIncluded(true);
|
||||||
}
|
}
|
||||||
} else if (region.type() == KSyntaxHighlighting::FoldingRegion::End) {
|
} else if (region.type() == KSyntaxHighlighting::FoldingRegion::End) {
|
||||||
setCurrentBlockState(qMax(0, currentBlockState() - 1));
|
TextDocumentLayout::changeBraceDepth(block, -1);
|
||||||
// if the folding end is at the end of the line move the current block into the fold
|
// if the folding end is at the end of the line move the current block into the fold
|
||||||
if (toEnd)
|
if (toEnd)
|
||||||
data->setFoldingEndIncluded(true);
|
data->setFoldingEndIncluded(true);
|
||||||
else
|
else
|
||||||
data->setFoldingIndent(currentBlockState());
|
data->setFoldingIndent(TextDocumentLayout::braceDepth(block));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user