Commit b1a024e5 authored by mae's avatar mae
Browse files

some corner cases fixing

parent cbd85651
...@@ -2378,8 +2378,8 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e) ...@@ -2378,8 +2378,8 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
extraAreaHighlightCollapseEndBlockNumber = d->m_highlightBlocksInfo.close.first(); extraAreaHighlightCollapseEndBlockNumber = d->m_highlightBlocksInfo.close.first();
endIsVisible = doc->findBlockByNumber(extraAreaHighlightCollapseEndBlockNumber).isVisible(); endIsVisible = doc->findBlockByNumber(extraAreaHighlightCollapseEndBlockNumber).isVisible();
if (TextBlockUserData::hasCollapseAfter( QTextBlock before = doc->findBlockByNumber(extraAreaHighlightCollapseBlockNumber-1);
doc->findBlockByNumber(extraAreaHighlightCollapseBlockNumber-1))) { if (TextBlockUserData::hasCollapseAfter(before)) {
extraAreaHighlightCollapseBlockNumber--; extraAreaHighlightCollapseBlockNumber--;
} }
} }
...@@ -2698,12 +2698,15 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e) ...@@ -2698,12 +2698,15 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
int collapseBoxWidth = fontMetrics().lineSpacing() + 1; int collapseBoxWidth = fontMetrics().lineSpacing() + 1;
if (e->pos().x() > extraArea()->width() - collapseBoxWidth) { if (e->pos().x() > extraArea()->width() - collapseBoxWidth) {
d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber(); d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber();
if (!TextBlockUserData::hasClosingCollapse(cursor.block())) if (TextBlockUserData::canCollapse(cursor.block())
|| !TextBlockUserData::hasClosingCollapse(cursor.block()))
d->extraAreaHighlightCollapseColumn = cursor.block().length()-1; d->extraAreaHighlightCollapseColumn = cursor.block().length()-1;
if (!d->m_displaySettings.m_fancyFoldingBar if (!d->m_displaySettings.m_fancyFoldingBar
&& TextBlockUserData::hasCollapseAfter(cursor.block())) { && TextBlockUserData::hasCollapseAfter(cursor.block())) {
d->extraAreaHighlightCollapseBlockNumber++; d->extraAreaHighlightCollapseBlockNumber++;
if (!TextBlockUserData::hasClosingCollapse(cursor.block().next())) d->extraAreaHighlightCollapseColumn = -1;
if (TextBlockUserData::canCollapse(cursor.block().next())
|| !TextBlockUserData::hasClosingCollapse(cursor.block().next()))
d->extraAreaHighlightCollapseColumn = cursor.block().next().length()-1; d->extraAreaHighlightCollapseColumn = cursor.block().next().length()-1;
} }
} }
...@@ -3299,8 +3302,9 @@ bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor, bo ...@@ -3299,8 +3302,9 @@ bool TextBlockUserData::findPreviousBlockOpenParenthesis(QTextCursor *cursor, bo
if (block == cursor->block()) { if (block == cursor->block()) {
if (position - block.position() <= paren.pos + (paren.type == Parenthesis::Closed ? 1 : 0)) if (position - block.position() <= paren.pos + (paren.type == Parenthesis::Closed ? 1 : 0))
continue; continue;
if (checkStartPosition && paren.type == Parenthesis::Opened && position == cursor->position()) if (checkStartPosition && paren.type == Parenthesis::Opened && paren.pos== cursor->position()) {
return true; return true;
}
} }
if (paren.type == Parenthesis::Closed) { if (paren.type == Parenthesis::Closed) {
++ignore; ++ignore;
...@@ -3820,6 +3824,10 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds) ...@@ -3820,6 +3824,10 @@ void BaseTextEditor::setDisplaySettings(const DisplaySettings &ds)
} }
d->m_displaySettings = ds; d->m_displaySettings = ds;
d->extraAreaHighlightCollapseBlockNumber = d->extraAreaHighlightCollapseColumn = -1;
d->m_highlightBlocksInfo = BaseTextEditorPrivateHighlightBlocks();
viewport()->update();
extraArea()->update();
} }
void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings) void BaseTextEditor::setStorageSettings(const StorageSettings &storageSettings)
......
...@@ -143,10 +143,12 @@ public: ...@@ -143,10 +143,12 @@ public:
inline static bool hasCollapseAfter(const QTextBlock & block) inline static bool hasCollapseAfter(const QTextBlock & block)
{ {
if (!block.isValid())
return false;
TextBlockUserData *data = static_cast<TextBlockUserData*>(block.userData()); TextBlockUserData *data = static_cast<TextBlockUserData*>(block.userData());
if (data && data->collapseMode() != NoCollapse) { if (data && data->collapseMode() != NoCollapse) {
return (data->collapseMode() == CollapseAfter); return false;
} else if (!data) { } else if (block.next().isValid()) {
data = static_cast<TextBlockUserData*>(block.next().userData()); data = static_cast<TextBlockUserData*>(block.next().userData());
if (data && data->collapseMode() == TextBlockUserData::CollapseThis && !data->m_ifdefedOut) if (data && data->collapseMode() == TextBlockUserData::CollapseThis && !data->m_ifdefedOut)
return true; return true;
......
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