From 78d0e7e12f3d164eec1b6b1851ad21f987b0dc6d Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 25 Dec 2023 21:24:54 +0100 Subject: [PATCH] Fix hidden results of long lines for "Find All ..." commands Fix some the results of "Find all in..." commands of long lines not being displayed, when the long lines are cut (its length > 2048). All the results displayed in the cut long lines will be kept as the current behaviour. Additionally, each result beyond the cut long line (2048) will be displayed as default mode (ie. each entry will be displayed, so user can double click on the entry line for reaching the result). Related: #12014 Fix #12023, close #14520 --- PowerEditor/installer/nativeLang/english.xml | 2 +- .../nativeLang/english_customizable.xml | 2 +- PowerEditor/installer/nativeLang/french.xml | 2 +- .../nativeLang/taiwaneseMandarin.xml | 2 +- .../src/ScintillaComponent/FindReplaceDlg.cpp | 22 +++++++++++++------ .../src/WinControls/Preference/preference.rc | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 6b7e0ffcd90e..31cbbfefd8ed 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1155,7 +1155,7 @@ You can define several column markers by using white space to separate the diffe - + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 55b5fed63aff..5e556ff65b98 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1155,7 +1155,7 @@ You can define several column markers by using white space to separate the diffe - + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index eb19b6f996ea..ac5e06360e89 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1156,7 +1156,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour - + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 805eb1b920ed..439685166405 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1108,7 +1108,7 @@ - + diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index fddc26e1704a..f68cfb9dc4fd 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -559,8 +559,11 @@ bool Finder::notify(SCNotification *notification) if (end > lineEndAbsPos) end = lineEndAbsPos; - _scintView.execute(SCI_SETSEL, begin, end); - _scintView.execute(SCI_SCROLLRANGE, begin, end); + if (begin < end) + { + _scintView.execute(SCI_SETSEL, begin, end); + _scintView.execute(SCI_SCROLLRANGE, begin, end); + } } break; @@ -4817,30 +4820,35 @@ const char* Finder::foundLine(FoundInfo fi, SearchResultMarkingLine miLine, cons headerStr += foundline; WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); const char* text2AddUtf8 = wmc.wchar2char(headerStr.c_str(), SC_CP_UTF8, &miLine._segmentPostions[0].first, &miLine._segmentPostions[0].second); // certainly utf8 here + size_t text2AddUtf8Len = strlen(text2AddUtf8); - if (isRepeatedLine) // if current line is the repeated line of previous one, and settings make per found line show once in the result even there are several found occurences in the same line + // if current line is the repeated line of previous one, and settings make per found line show ONCE in the result even there are several found occurences in the same line, for: + if ((isRepeatedLine && + ((text2AddUtf8Len < SC_SEARCHRESULT_LINEBUFFERMAXLENGTH) || // 1. All displayed whole lines, in which it contains all the occurrences. + ((text2AddUtf8Len >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH && miLine._segmentPostions[0].second < SC_SEARCHRESULT_LINEBUFFERMAXLENGTH))))) // 2. or the cut lines but the segments are displayed. For the segments displayed beyond displayed (non-cut part), go to default mode. { // Add start and end markers into the previous line's info for colourizing _pMainMarkings->back()._segmentPostions.push_back(std::pair(miLine._segmentPostions[0].first, miLine._segmentPostions[0].second)); _pMainFoundInfos->back()._ranges.push_back(fi._ranges.back()); + return ""; } else // default mode: allow same found line has several entries in search result if the searched occurrence is matched several times in the same line { _pMainFoundInfos->push_back(fi); - size_t len = strlen(text2AddUtf8); - if (len >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH) + + if (text2AddUtf8Len >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH) { const char* endOfLongLine = " ...\r\n"; // perfectly Utf8-encoded already size_t lenEndOfLongLine = strlen(endOfLongLine); size_t cut = SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - lenEndOfLongLine - 1; - while ((cut > 0) && (!Utf8::isValid(&text2AddUtf8[cut], (int)(len - cut)))) + while ((cut > 0) && (!Utf8::isValid(&text2AddUtf8[cut], (int)(text2AddUtf8Len - cut)))) cut--; memcpy((void*)&text2AddUtf8[cut], endOfLongLine, lenEndOfLongLine + 1); - len = cut + lenEndOfLongLine; + text2AddUtf8Len = cut + lenEndOfLongLine; } _pMainMarkings->push_back(miLine); diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 577f7f03d523..996711780a39 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -363,7 +363,7 @@ BEGIN CONTROL "Find dialog remains open after search that outputs to results window", IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 89, 350, 10 CONTROL "Confirm Replace All in All Opened Documents", IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 104, 350, 10 CONTROL "Replace: Don't move to the following occurrence", IDC_CHECK_REPLACEANDSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 119, 350, 10 - CONTROL "Search Result window: show only one entry per found line", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 134, 350, 10 + CONTROL "Search Result window: show only one entry per found line if possible", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 134, 350, 10 END