[FarGroup/FarManager] master: Fix tmppanel losing files that differ in letter case (3a0a4e80d)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Nov 8, 2025, 12:45:54 PM (8 days ago) Nov 8
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/3a0a4e80d0897c17cab90599efaf1c41618583c5

>---------------------------------------------------------------

commit 3a0a4e80d0897c17cab90599efaf1c41618583c5
Author: ssvine <7940516...@users.noreply.github.com>
Date: Sat Nov 8 12:56:46 2025 +0300

Fix tmppanel losing files that differ in letter case


>---------------------------------------------------------------

3a0a4e80d0897c17cab90599efaf1c41618583c5
plugins/tmppanel/TmpClass.cpp | 4 ++--
plugins/tmppanel/TmpPanel.hpp | 1 -
plugins/tmppanel/changelog | 4 ++++
plugins/tmppanel/headers.hpp | 34 ++++++++++++++++++++++++++++++++++
plugins/tmppanel/version.hpp | 2 +-
5 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/plugins/tmppanel/TmpClass.cpp b/plugins/tmppanel/TmpClass.cpp
index 88baeb5a9..3ce4cca74 100644
--- a/plugins/tmppanel/TmpClass.cpp
+++ b/plugins/tmppanel/TmpClass.cpp
@@ -380,7 +380,7 @@ void TmpPanel::UpdateItems(const bool ShowOwners, const bool ShowLinks)
m_LastOwnersRead = ShowOwners;
m_LastLinksRead = ShowLinks;

- std::unordered_map<string_view, PluginPanelItem*> SameFolderItems;
+ unordered_string_map_icase<PluginPanelItem*> SameFolderItems;

auto NameDataIterator = m_Panel->StringData.begin();
for (auto CurItem = m_Panel->Items.begin(), end = m_Panel->Items.end(); CurItem != end; ++CurItem, ++NameDataIterator)
@@ -411,7 +411,7 @@ void TmpPanel::UpdateItems(const bool ShowOwners, const bool ShowLinks)
// несколько файлов из одного и того же каталога. При этом
// FindFirstFile() делается один раз на каталог, а не отдельно для
// каждого файла.
- if (SameFolderItemsNumber > 2)
+ if (SameFolderItemsNumber >= 2)
{
WIN32_FIND_DATA FindData;
const auto FindFile = Dir + L"*"sv;
diff --git a/plugins/tmppanel/TmpPanel.hpp b/plugins/tmppanel/TmpPanel.hpp
index 666537f26..1a0b86a80 100644
--- a/plugins/tmppanel/TmpPanel.hpp
+++ b/plugins/tmppanel/TmpPanel.hpp
@@ -36,7 +36,6 @@ struct shared_data
inline shared_data* SharedData;

inline PluginStartupInfo PsInfo;
-inline FarStandardFunctions FSF;

#define NT_MAX_PATH 32768

diff --git a/plugins/tmppanel/changelog b/plugins/tmppanel/changelog
index a577c7268..b471266e0 100644
--- a/plugins/tmppanel/changelog
+++ b/plugins/tmppanel/changelog
@@ -1,3 +1,7 @@
+ssvine 2025-11-08 12:56:45+03:00 - build 122
+
+1. gh-1041: Temporary panel loses files that differ in letter case
+
drkns 2024-11-24 11:48:49+00:00 - build 121

1. Remove quadratic complexity from panel updates.
diff --git a/plugins/tmppanel/headers.hpp b/plugins/tmppanel/headers.hpp
index f999b92d1..aa063d88f 100644
--- a/plugins/tmppanel/headers.hpp
+++ b/plugins/tmppanel/headers.hpp
@@ -10,6 +10,7 @@
#include <string>
#include <string_view>
#include <vector>
+#include <unordered_map>

#include <cstdlib>
#include <cwctype>
@@ -28,5 +29,38 @@ inline namespace literals
using namespace std::literals;
}

+inline FarStandardFunctions FSF;
+
+struct [[nodiscard]] string_comparer_icase
+{
+ [[nodiscard]]
+ size_t operator()(const string_view Str) const
+ {
+ string UpStr(Str);
+ FSF.LUpperBuf(const_cast<wchar_t*>(UpStr.c_str()), UpStr.size());
+ return std::hash<string>{}(UpStr);
+ }
+
+ [[nodiscard]]
+ bool operator()(const string_view Str1, const string_view Str2) const
+ {
+ if (Str1 == Str2)
+ return true;
+ if (Str1.size() != Str2.size())
+ return false;
+ return std::equal(Str1.begin(), Str1.end(), Str2.begin(),
+ [](wchar_t c1, wchar_t c2)
+ {
+ if (c1 == c2)
+ return true;
+ FSF.LUpperBuf(&c1, 1);
+ FSF.LUpperBuf(&c2, 1);
+ return c1 == c2;
+ });
+ }
+};
+
+template<typename T>
+using unordered_string_map_icase = std::unordered_map<string, T, string_comparer_icase, string_comparer_icase>;

#endif // HEADERS_HPP_74234F4A_8C20_4AE2_A532_E93F003489D5
diff --git a/plugins/tmppanel/version.hpp b/plugins/tmppanel/version.hpp
index 9d644c9f3..50c2b04f5 100644
--- a/plugins/tmppanel/version.hpp
+++ b/plugins/tmppanel/version.hpp
@@ -1,6 +1,6 @@
#include <farversion.hpp>

-#define PLUGIN_BUILD 121
+#define PLUGIN_BUILD 122
#define PLUGIN_DESC L"Temporary Panel for Far Manager"
#define PLUGIN_NAME L"TmpPanel"
#define PLUGIN_FILENAME L"TmpPanel.dll"


Reply all
Reply to author
Forward
0 new messages