Fix "Hide lines" command hiding unselected lines issue

To solve this issue, lambda removeMarker can be set to only remove just begin or end marker. By doing so, the process of merging adjacent hidden sections is limited and as a result, lines that shouldn't be hidden remain visible.

Fix #14166, close #14167
This commit is contained in:
Adrian Kulawik 2023-09-21 11:08:11 +02:00 committed by Don Ho
parent 1c27e64126
commit 4ba92b04ec
1 changed files with 8 additions and 8 deletions

View File

@ -3662,9 +3662,9 @@ void ScintillaEditView::hideLines()
int scope = 0;
bool recentMarkerWasOpen = false;
auto removeMarker = [this, &scope, &recentMarkerWasOpen](size_t line)
auto removeMarker = [this, &scope, &recentMarkerWasOpen](size_t line, int markerMask)
{
auto state = execute(SCI_MARKERGET, line);
auto state = execute(SCI_MARKERGET, line) & markerMask;
bool closePresent = (state & (1 << MARK_HIDELINESEND)) != 0;
bool openPresent = (state & (1 << MARK_HIDELINESBEGIN)) != 0;
@ -3687,8 +3687,8 @@ void ScintillaEditView::hideLines()
size_t endMarker = endLine + 1;
// Remove all previous markers in between new ones
for (size_t i = startMarker + 1; i < endMarker; ++i)
removeMarker(i);
for (size_t i = startLine; i <= endLine; ++i)
removeMarker(i, (1 << MARK_HIDELINESBEGIN) | (1 << MARK_HIDELINESEND));
// When hiding lines just below/above other hidden lines,
// merge them into one hidden section:
@ -3699,10 +3699,10 @@ void ScintillaEditView::hideLines()
// Both "while" loops are executed (merge with above AND below hidden section):
while (scope == 0)
removeMarker(--startMarker);
removeMarker(--startMarker, 1 << MARK_HIDELINESBEGIN);
while (scope != 0)
removeMarker(++endMarker);
removeMarker(++endMarker, 1 << MARK_HIDELINESEND);
}
else
{
@ -3710,10 +3710,10 @@ void ScintillaEditView::hideLines()
// If true, only one "while" loop is executed (merge with adjacent hidden section):
while (scope < 0)
removeMarker(--startMarker);
removeMarker(--startMarker, 1 << MARK_HIDELINESBEGIN);
while (scope > 0)
removeMarker(++endMarker);
removeMarker(++endMarker, 1 << MARK_HIDELINESEND);
}
execute(SCI_MARKERADD, startMarker, MARK_HIDELINESBEGIN);