Fix hide lines merging to avoid merging across a visible line

Fix #12844, close #13681
This commit is contained in:
cynthplusplus 2023-05-21 07:24:11 -04:00 committed by Don Ho
parent f6e1b2cab6
commit c49692cb47
1 changed files with 20 additions and 17 deletions

View File

@ -3688,7 +3688,7 @@ void ScintillaEditView::hideLines()
size_t endMarker = endLine + 1; size_t endMarker = endLine + 1;
// Remove all previous markers in between new ones // Remove all previous markers in between new ones
for (size_t i = startMarker; i <= endMarker; ++i) for (size_t i = startMarker + 1; i < endMarker; ++i)
removeMarker(i); removeMarker(i);
// When hiding lines just below/above other hidden lines, // When hiding lines just below/above other hidden lines,
@ -3735,6 +3735,7 @@ bool ScintillaEditView::markerMarginClick(intptr_t lineNumber)
//Special func on buffer. First call show with location of opening marker. Then remove the marker manually //Special func on buffer. First call show with location of opening marker. Then remove the marker manually
if (openPresent) if (openPresent)
{ {
closePresent = false; // when there are two overlapping markers, always open the lower section
_currentBuffer->setHideLineChanged(false, lineNumber); _currentBuffer->setHideLineChanged(false, lineNumber);
} }
@ -3828,7 +3829,19 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
for (auto i = searchStart; i < maxLines; ++i) for (auto i = searchStart; i < maxLines; ++i)
{ {
auto state = execute(SCI_MARKERGET, i); auto state = execute(SCI_MARKERGET, i);
if ( ((state & (1 << MARK_HIDELINESEND)) != 0) ) if ((state & (1 << MARK_HIDELINESBEGIN)) != 0 && !isInSection)
{
isInSection = true;
if (doDelete)
{
execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN);
}
else
{
startShowing = i + 1;
}
}
else if ( (state & (1 << MARK_HIDELINESEND)) != 0)
{ {
if (doDelete) if (doDelete)
{ {
@ -3837,6 +3850,7 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
{ {
return; //done, only single section requested return; //done, only single section requested
} //otherwise keep going } //otherwise keep going
isInSection = false;
} }
else if (isInSection) else if (isInSection)
{ {
@ -3848,6 +3862,7 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
} }
else else
{ {
isInSection = false; // assume we passed the close tag
continue; continue;
} }
} }
@ -3859,18 +3874,6 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
isInSection = false; isInSection = false;
} }
} }
if ((state & (1 << MARK_HIDELINESBEGIN)) != 0)
{
if (doDelete)
{
execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN);
}
else
{
isInSection = true;
startShowing = i+1;
}
}
auto levelLine = execute(SCI_GETFOLDLEVEL, i, 0); auto levelLine = execute(SCI_GETFOLDLEVEL, i, 0);
if (levelLine & SC_FOLDLEVELHEADERFLAG) if (levelLine & SC_FOLDLEVELHEADERFLAG)