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;
// 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);
// When hiding lines just below/above other hidden lines,
@ -3731,10 +3731,11 @@ bool ScintillaEditView::markerMarginClick(intptr_t lineNumber)
if (!openPresent && !closePresent)
return false;
//Special func on buffer. First call show with location of opening marker. Then remove the marker manually
if (openPresent)
{
closePresent = false; // when there are two overlapping markers, always open the lower section
_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)
{
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)
{
@ -3837,9 +3850,10 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
{
return; //done, only single section requested
} //otherwise keep going
isInSection = false;
}
else if (isInSection)
{
else if (isInSection)
{
if (startShowing >= i)
{ //because of fold skipping, we passed the close tag. In that case we cant do anything
if (!endOfDoc)
@ -3848,6 +3862,7 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
}
else
{
isInSection = false; // assume we passed the close tag
continue;
}
}
@ -3859,18 +3874,6 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
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);
if (levelLine & SC_FOLDLEVELHEADERFLAG)