From 467182602a4331342015f5ad99a295e76b9da8bd Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 17 Nov 2024 05:26:02 +0100 Subject: [PATCH] Fix selected pathnames in search results localization issue Bug introduced by commit: https://github.com/notepad-plus-plus/notepad-plus-plus/commit/b8224808bdb6f9eaf94c066219634715703828da#diff-a6ac7ceba70d88bf1547fd1defd760bd55052dcdb78c44f9d46d99ef1f450472L1722 Fix by https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15741#issuecomment-2480350071 Close #15813 --- PowerEditor/installer/nativeLang/english.xml | 4 +-- .../nativeLang/english_customizable.xml | 4 +-- PowerEditor/src/Parameters.h | 4 +-- .../src/ScintillaComponent/FindReplaceDlg.cpp | 32 +++++++++++-------- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 2 +- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 0fe080f94..d624501c9 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1720,9 +1720,9 @@ Find in all files but exclude all folders log or logs recursively: - + - + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 3e3703fab..8c6a7f955 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1718,9 +1718,9 @@ Find in all files but exclude all folders log or logs recursively: - + - + diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index c59f8ca6f..8742c0101 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1396,12 +1396,12 @@ struct HLSColour void loadFromRGB(COLORREF rgb) { ColorRGBToHLS(rgb, &_hue, &_lightness, &_saturation); } COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); } - COLORREF toRGB4DarkModWithTuning(int lightnessMore, int saturationLess) const { + COLORREF toRGB4DarkModeWithTuning(int lightnessMore, int saturationLess) const { return ColorHLSToRGB(_hue, static_cast(static_cast(_lightness) + lightnessMore), static_cast(static_cast(_saturation) - saturationLess)); } - COLORREF toRGB4DarkMod() const { return toRGB4DarkModWithTuning(50, 20); } + COLORREF toRGB4DarkMod() const { return toRGB4DarkModeWithTuning(50, 20); } }; struct UdlXmlFileState final { diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index d5476a0d0..aab7f006c 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -703,29 +703,33 @@ vector Finder::getResultFilePaths(bool onlyInSelectedText) const toLine = _scintView.execute(SCI_GETLINECOUNT) - 1; } + size_t len = _pMainFoundInfos->size(); // First, get the number of elements in the container for (size_t line = fromLine; line <= toLine; ++line) { + bool found = false; // Was it found? const int lineFoldLevel = _scintView.execute(SCI_GETFOLDLEVEL, line) & SC_FOLDLEVELNUMBERMASK; if (lineFoldLevel == fileHeaderLevel) { - wstring lineStr = _scintView.getLine(line); - - // fileHeaderLevel line format examples: - // spacespaceD:\folder\file.ext (2 hits) - // spacespacenew 1 (1 hit) - const size_t startIndex = 2; // for number of leading spaces - auto endIndex = lineStr.find_last_of(L'('); - --endIndex; // adjust for space in front of ( - wstring path = lineStr.substr(startIndex, endIndex - startIndex); - - // make sure that path is not already in before adding - if (std::find(paths.begin(), paths.end(), path) == paths.end()) + line++; // Move to the next line + if (line < len) + found = true; // Found it + } + else if (lineFoldLevel == resultLevel) + { + if (line < len) + found = true; // Found it + } + if (found) + { + wstring& path = (*_pMainFoundInfos)[line]._fullPath; // Get the path from the container + if (path.find('\\') != std::wstring::npos && std::find(paths.begin(), paths.end(), path) == paths.end()) // Contains a path separator and does not exist in the container { paths.push_back(path); } } } + return paths; } @@ -5736,12 +5740,12 @@ intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam wstring copyLines = pNativeSpeaker->getLocalizedStrFromID("finder-copy", L"Copy Selected Line(s)"); wstring copyVerbatim = pNativeSpeaker->getNativeLangMenuString(IDM_EDIT_COPY, L"Copy", true); copyVerbatim += L"\tCtrl+C"; - wstring copyPaths = pNativeSpeaker->getLocalizedStrFromID("finder-copy-paths", L"Copy Selected Pathname(s)"); + wstring copyPaths = pNativeSpeaker->getLocalizedStrFromID("finder-copy-selected-paths", L"Copy Selected Pathname(s)"); wstring selectAll = pNativeSpeaker->getNativeLangMenuString(IDM_EDIT_SELECTALL, L"Select all", true); selectAll += L"\tCtrl+A"; wstring clearAll = pNativeSpeaker->getLocalizedStrFromID("finder-clear-all", L"Clear all"); wstring purgeForEverySearch = pNativeSpeaker->getLocalizedStrFromID("finder-purge-for-every-search", L"Purge for every search"); - wstring openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-all", L"Open Selected Pathname(s)"); + wstring openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-selected-paths", L"Open Selected Pathname(s)"); wstring wrapLongLines = pNativeSpeaker->getLocalizedStrFromID("finder-wrap-long-lines", L"Word wrap long lines"); tmp.push_back(MenuItemUnit(NPPM_INTERNAL_FINDINFINDERDLG, findInFinder)); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 37336ea2b..fd6357b6f 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -1479,7 +1479,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) if (_currentHoverTabItem == nTab && brushColour != colorActiveBg) // hover on a "darker" inactive tab { HLSColour hls(brushColour); - brushColour = hls.toRGB4DarkModWithTuning(15, 0); // make it lighter slightly + brushColour = hls.toRGB4DarkModeWithTuning(15, 0); // make it lighter slightly } hBrush = ::CreateSolidBrush(brushColour);