From 059bca3315dbd71fbf235c8bc87eaacbd87a3cec Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 30 Jun 2022 17:29:39 +0200 Subject: [PATCH] Fix 1 entry per line in Search result UTF8 marked wronly issue Fix CJK, Hebrew, Arabic and other Languages in UTF8 marked wronly issue in in Search result while "1 entry per line" option enabled. The option in question can be enabled in RTL mode now with this commit. --- PowerEditor/installer/nativeLang/corsican.xml | 2 +- PowerEditor/installer/nativeLang/english.xml | 2 +- PowerEditor/installer/nativeLang/french.xml | 2 +- PowerEditor/installer/nativeLang/german.xml | 2 +- PowerEditor/installer/nativeLang/japanese.xml | 2 +- PowerEditor/installer/nativeLang/russian.xml | 2 +- .../nativeLang/taiwaneseMandarin.xml | 2 +- .../src/ScintillaComponent/FindReplaceDlg.cpp | 24 +++++++------------ .../src/WinControls/Preference/preference.rc | 2 +- 9 files changed, 16 insertions(+), 24 deletions(-) diff --git a/PowerEditor/installer/nativeLang/corsican.xml b/PowerEditor/installer/nativeLang/corsican.xml index 7f8777d3e..3be2dcca3 100644 --- a/PowerEditor/installer/nativeLang/corsican.xml +++ b/PowerEditor/installer/nativeLang/corsican.xml @@ -1078,7 +1078,7 @@ Pudete definisce parechji marcatori di culonna impieghendu un spaziu per staccà - + diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 967134260..58fa26434 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1048,7 +1048,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 2484a06c6..a1917a659 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1048,7 +1048,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour - + diff --git a/PowerEditor/installer/nativeLang/german.xml b/PowerEditor/installer/nativeLang/german.xml index 0ce6a0649..6f99237aa 100644 --- a/PowerEditor/installer/nativeLang/german.xml +++ b/PowerEditor/installer/nativeLang/german.xml @@ -1057,7 +1057,7 @@ Mehrere Spaltenmarkierungen können definiert werden, indem die Zahlen durch Lee - + diff --git a/PowerEditor/installer/nativeLang/japanese.xml b/PowerEditor/installer/nativeLang/japanese.xml index 277aa3b28..7789c3611 100644 --- a/PowerEditor/installer/nativeLang/japanese.xml +++ b/PowerEditor/installer/nativeLang/japanese.xml @@ -1052,7 +1052,7 @@ - + diff --git a/PowerEditor/installer/nativeLang/russian.xml b/PowerEditor/installer/nativeLang/russian.xml index e51bd20ab..bb089c5f5 100644 --- a/PowerEditor/installer/nativeLang/russian.xml +++ b/PowerEditor/installer/nativeLang/russian.xml @@ -1053,7 +1053,7 @@ Updated to v8.4.3: - + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index bf9d0bc20..130320d0c 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1036,7 +1036,7 @@ - + diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 99f5b122d..bb550c7a6 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -2709,6 +2709,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl intptr_t start_mark = targetStart - lstart; intptr_t end_mark = targetEnd - lstart; + //intptr_t start_mark2 = start_mark; + //intptr_t end_mark2 = end_mark; + pEditView->getGenericText(lineBuf, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH, lstart, lend, &start_mark, &end_mark); generic_string line = lineBuf; @@ -4356,9 +4359,7 @@ void Finder::add(FoundInfo fi, SearchResultMarkingLine miLine, const TCHAR* foun NppParameters& nppParam = NppParameters::getInstance(); NppGUI& nppGUI = nppParam.getNppGUI(); - bool isRTL = _scintView.isTextDirectionRTL(); - - if (nppGUI._finderShowOnlyOneEntryPerFoundLine && !isRTL) // several occurrence colourizing in Search result doesn't support for RTL mode + if (nppGUI._finderShowOnlyOneEntryPerFoundLine) { if (_previousLineNumber == -1) { @@ -4387,31 +4388,23 @@ void Finder::add(FoundInfo fi, SearchResultMarkingLine miLine, const TCHAR* foun headerStr += lineNumberStr; headerStr += TEXT(": "); + miLine._segmentPostions[0].first += headerStr.length(); + miLine._segmentPostions[0].second += headerStr.length(); + 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 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 { - std::string utf8Header = wmc.wchar2char(headerStr.c_str(), SC_CP_UTF8); // certainly utf8 here - - miLine._segmentPostions[0].first += utf8Header.length(); - miLine._segmentPostions[0].second += utf8Header.length(); - // 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()); } 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 { - miLine._segmentPostions[0].first += headerStr.length(); - miLine._segmentPostions[0].second += headerStr.length(); - _pMainFoundInfos->push_back(fi); - headerStr += foundline; - - const char* text2AddUtf8 = wmc.wchar2char(headerStr.c_str(), SC_CP_UTF8, &miLine._segmentPostions[0].first, &miLine._segmentPostions[0].second); // certainly utf8 here size_t len = strlen(text2AddUtf8); - if (len >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH) { const char* endOfLongLine = " ...\r\n"; // perfectly Utf8-encoded already @@ -4571,7 +4564,6 @@ void Finder::beginNewFilesSearch() { NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); _prefixLineStr = pNativeSpeaker->getLocalizedStrFromID("find-result-line-prefix", TEXT("Line")); - //_prefixLineStr = TEXT("Line"); // Use SCI_SETSEL(0, 0) instead of SCI_SETCURRENTPOS(0) to workaround // an eventual regression or a change of behaviour in Scintilla 4.4.6 diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index c87e32c7e..5aee922cd 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -334,7 +334,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,40,350,10 CONTROL "Confirm Replace All in All Opened Documents",IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,37,55,350,10 CONTROL "Replace: Don't move to the following occurrence", IDC_CHECK_REPLACEANDSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 70, 350, 10 - CONTROL "Search Result window: show only one entry per found line (not applied to RTL mode)", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 85, 350, 10 + CONTROL "Search Result window: show only one entry per found line", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 85, 350, 10 END