From b717041b10bcd5ce501105c6f6b556739f3c029a Mon Sep 17 00:00:00 2001 From: rkotten Date: Wed, 1 Mar 2023 10:38:32 +0100 Subject: [PATCH 1/3] +fix: find marker next/prev --- src/Edit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index bd1b6ad55..3f5213d8b 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -9433,7 +9433,6 @@ void EditBookmarkNext(HWND hwnd, DocLn iLine) DocLn iNextLine = NOT_FOUND_LN; bool bWrapedAround = true; do { - bWrapedAround = !bWrapedAround; int bitmask = SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK()); if (!bitmask) { bitmask = BOOKMARK_BITMASK(); @@ -9451,9 +9450,9 @@ void EditBookmarkNext(HWND hwnd, DocLn iLine) iNextLine = _MarkerNext(iLine + 1, bitmask); // find change history marker } if (iNextLine == NOT_FOUND_LN) { + // initial search not started from beginning? if (iLine != 0) { iLine = 0; - bWrapedAround = !bWrapedAround; } } else { // check for consecutive change marker @@ -9464,6 +9463,7 @@ void EditBookmarkNext(HWND hwnd, DocLn iLine) } } } + bWrapedAround = !bWrapedAround; } while ((iNextLine == NOT_FOUND_LN) && !bWrapedAround); if (iNextLine != NOT_FOUND_LN) { @@ -9494,7 +9494,6 @@ void EditBookmarkPrevious(HWND hwnd, DocLn iLine) DocLn iPrevLine = NOT_FOUND_LN; bool bWrapedAround = true; do { - bWrapedAround = !bWrapedAround; int bitmask = SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK()); if (!bitmask) { bitmask = BOOKMARK_BITMASK(); @@ -9513,9 +9512,9 @@ void EditBookmarkPrevious(HWND hwnd, DocLn iLine) iPrevLine = _MarkerPrevious(iLine - 1, bitmask); // find change history marker } if (iPrevLine == NOT_FOUND_LN) { + // initial search not started from bottom? if (iLine != SciCall_GetLineCount()) { iLine = SciCall_GetLineCount(); - bWrapedAround = !bWrapedAround; } } else { // check for consecutive change marker @@ -9526,10 +9525,14 @@ void EditBookmarkPrevious(HWND hwnd, DocLn iLine) } } } + bWrapedAround = !bWrapedAround; } while ((iPrevLine == NOT_FOUND_LN) && !bWrapedAround); if (iPrevLine != NOT_FOUND_LN) { - SciCall_GotoLine(iPrevLine); + // find beginning of consecutive change marker + int const bm = SciCall_MarkerGet(iPrevLine); + while ((--iPrevLine >= 0) && (bm == SciCall_MarkerGet(iPrevLine))) {} + SciCall_GotoLine(iPrevLine + 1); } } From 2707dad476471632c545da1fe64ea75696ff186f Mon Sep 17 00:00:00 2001 From: rkotten Date: Wed, 1 Mar 2023 10:53:09 +0100 Subject: [PATCH 2/3] +fix: find consecutive change marker begin --- src/Edit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 3f5213d8b..022d26d76 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -9413,6 +9413,10 @@ void EditSetBookmarkList(HWND hwnd, LPCWSTR pszBookMarks) #define NOT_FOUND_LN ((DocLn)-1) +__forceinline int _GetAllNP3Markers(const DocLn iLine) { + return (SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK())); +} + static inline DocLn _MarkerNext(const DocLn iLine, const int bitmask) { if (bitmask & CHANGE_HISTORY_MARKER_BITMASK()) { @@ -9433,7 +9437,7 @@ void EditBookmarkNext(HWND hwnd, DocLn iLine) DocLn iNextLine = NOT_FOUND_LN; bool bWrapedAround = true; do { - int bitmask = SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK()); + int bitmask = _GetAllNP3Markers(iLine); if (!bitmask) { bitmask = BOOKMARK_BITMASK(); } @@ -9494,7 +9498,7 @@ void EditBookmarkPrevious(HWND hwnd, DocLn iLine) DocLn iPrevLine = NOT_FOUND_LN; bool bWrapedAround = true; do { - int bitmask = SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK()); + int bitmask = _GetAllNP3Markers(iLine); if (!bitmask) { bitmask = BOOKMARK_BITMASK(); } @@ -9530,8 +9534,8 @@ void EditBookmarkPrevious(HWND hwnd, DocLn iLine) if (iPrevLine != NOT_FOUND_LN) { // find beginning of consecutive change marker - int const bm = SciCall_MarkerGet(iPrevLine); - while ((--iPrevLine >= 0) && (bm == SciCall_MarkerGet(iPrevLine))) {} + int const bm = _GetAllNP3Markers(iPrevLine); + while ((--iPrevLine >= 0) && (bm & SciCall_MarkerGet(iPrevLine))) {} SciCall_GotoLine(iPrevLine + 1); } } From 750364ace034498c5d46c7d240a093920354400e Mon Sep 17 00:00:00 2001 From: rkotten Date: Wed, 1 Mar 2023 11:13:01 +0100 Subject: [PATCH 3/3] +enh: Goto next/prev markers: respect last searched markers --- src/Edit.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 022d26d76..0f1759d85 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -9417,6 +9417,15 @@ __forceinline int _GetAllNP3Markers(const DocLn iLine) { return (SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK())); } +static int _RespectLastSearch(const int bitmask) { + static int s_LastSearchBitmask = 0; + if (!(bitmask & s_LastSearchBitmask)) { + s_LastSearchBitmask = bitmask; + } + return s_LastSearchBitmask; +} + + static inline DocLn _MarkerNext(const DocLn iLine, const int bitmask) { if (bitmask & CHANGE_HISTORY_MARKER_BITMASK()) { @@ -9437,7 +9446,7 @@ void EditBookmarkNext(HWND hwnd, DocLn iLine) DocLn iNextLine = NOT_FOUND_LN; bool bWrapedAround = true; do { - int bitmask = _GetAllNP3Markers(iLine); + int bitmask = _RespectLastSearch(_GetAllNP3Markers(iLine)); if (!bitmask) { bitmask = BOOKMARK_BITMASK(); } @@ -9498,7 +9507,7 @@ void EditBookmarkPrevious(HWND hwnd, DocLn iLine) DocLn iPrevLine = NOT_FOUND_LN; bool bWrapedAround = true; do { - int bitmask = _GetAllNP3Markers(iLine); + int bitmask = _RespectLastSearch(_GetAllNP3Markers(iLine)); if (!bitmask) { bitmask = BOOKMARK_BITMASK(); }