From 4ba92b04ec01132978365a79c4898c8f3285b088 Mon Sep 17 00:00:00 2001 From: Adrian Kulawik Date: Thu, 21 Sep 2023 11:08:11 +0200 Subject: [PATCH] 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 --- .../src/ScintillaComponent/ScintillaEditView.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 5ac755b1e..e163bb433 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -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);