Commit d937ee55 authored by mae's avatar mae
Browse files

tweak collapse/expand short cuts, and do not draw collpase boxes

in ifdefed out sections
parent 18d84955
......@@ -2283,9 +2283,11 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
}
}
collapseAfter = (userData->collapseMode() == TextBlockUserData::CollapseAfter);
collapseThis = (userData->collapseMode() == TextBlockUserData::CollapseThis);
hasClosingCollapse = userData->hasClosingCollapse() && (previousBraceDepth > 0);
if (!userData->ifdefedOut()) {
collapseAfter = (userData->collapseMode() == TextBlockUserData::CollapseAfter);
collapseThis = (userData->collapseMode() == TextBlockUserData::CollapseThis);
hasClosingCollapse = userData->hasClosingCollapse() && (previousBraceDepth > 0);
}
}
if (d->m_codeFoldingVisible) {
......@@ -2318,10 +2320,12 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
bool collapseNext = nextBlockUserData
&& nextBlockUserData->collapseMode()
== TextBlockUserData::CollapseThis;
== TextBlockUserData::CollapseThis
&& !nextBlockUserData->ifdefedOut();
bool nextHasClosingCollapse = nextBlockUserData
&& nextBlockUserData->hasClosingCollapseInside();
&& nextBlockUserData->hasClosingCollapseInside()
&& nextBlockUserData->ifdefedOut();
bool drawBox = ((collapseAfter || collapseNext) && !nextHasClosingCollapse);
......@@ -3397,9 +3401,12 @@ void BaseTextEditor::collapse()
TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
QTC_ASSERT(documentLayout, return);
QTextBlock block = textCursor().block();
QTextBlock curBlock = block;
while (block.isValid()) {
if (TextBlockUserData::canCollapse(block) && block.next().isVisible()) {
if ((block.next().userState()) >> 8 <= (textCursor().block().userState() >> 8))
if (block == curBlock)
break;
if ((block.next().userState()) >> 8 <= (curBlock.previous().userState() >> 8))
break;
}
block = block.previous();
......
......@@ -138,7 +138,7 @@ public:
TextBlockUserData *data = static_cast<TextBlockUserData*>(block.userData());
if (!data || data->collapseMode() != CollapseAfter) {
data = static_cast<TextBlockUserData*>(block.next().userData());
if (!data || data->collapseMode() != TextBlockUserData::CollapseThis)
if (!data || data->collapseMode() != TextBlockUserData::CollapseThis || data->m_ifdefedOut)
data = 0;
}
return data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment