mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[PowerRename] Sort files alphabetically as in file explorer (#15269)
* [PowerRename] Sort files * Run spellcheck
This commit is contained in:
2
.github/actions/spell-check/expect.txt
vendored
2
.github/actions/spell-check/expect.txt
vendored
@@ -246,6 +246,7 @@ CMINVOKECOMMANDINFO
|
||||
CMINVOKECOMMANDINFOEX
|
||||
CMock
|
||||
CMONITORS
|
||||
cmp
|
||||
cmyk
|
||||
cnt
|
||||
coclass
|
||||
@@ -1764,6 +1765,7 @@ SHOWNOACTIVATE
|
||||
SHOWNORMAL
|
||||
SHOWWINDOW
|
||||
shtypes
|
||||
SICHINT
|
||||
sid
|
||||
siex
|
||||
SIGABRT
|
||||
|
||||
@@ -89,7 +89,22 @@ HRESULT CPowerRenameEnum::_ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ int d
|
||||
|
||||
ULONG celtFetched;
|
||||
CComPtr<IShellItem> spsi;
|
||||
while ((S_OK == pesi->Next(1, &spsi, &celtFetched)) && (SUCCEEDED(hr)))
|
||||
std::vector<CComPtr<IShellItem>> items;
|
||||
|
||||
while ((S_OK == pesi->Next(1, &spsi, &celtFetched)))
|
||||
{
|
||||
items.push_back(spsi);
|
||||
spsi = nullptr;
|
||||
}
|
||||
|
||||
auto cmpShellItems = [](CComPtr<IShellItem> l, CComPtr<IShellItem> r) {
|
||||
int res = 0;
|
||||
l->Compare(r, SICHINT_DISPLAY, &res);
|
||||
return res < 0;
|
||||
};
|
||||
std::sort(items.begin(), items.end(), cmpShellItems);
|
||||
|
||||
for (const auto& item : items)
|
||||
{
|
||||
if (m_canceled)
|
||||
{
|
||||
@@ -104,7 +119,7 @@ HRESULT CPowerRenameEnum::_ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ int d
|
||||
// Failure may be valid if we come across a shell item that does
|
||||
// not support a file system path. In that case we simply ignore
|
||||
// the item.
|
||||
if (SUCCEEDED(spFactory->Create(spsi, &spNewItem)))
|
||||
if (SUCCEEDED(spFactory->Create(item, &spNewItem)))
|
||||
{
|
||||
spNewItem->PutDepth(depth);
|
||||
hr = m_spsrm->AddItem(spNewItem);
|
||||
@@ -115,7 +130,7 @@ HRESULT CPowerRenameEnum::_ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ int d
|
||||
{
|
||||
// Bind to the IShellItem for the IEnumShellItems interface
|
||||
CComPtr<IEnumShellItems> spesiNext;
|
||||
hr = spsi->BindToHandler(nullptr, BHID_EnumItems, IID_PPV_ARGS(&spesiNext));
|
||||
hr = item->BindToHandler(nullptr, BHID_EnumItems, IID_PPV_ARGS(&spesiNext));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// Parse the folder contents recursively
|
||||
@@ -125,8 +140,10 @@ HRESULT CPowerRenameEnum::_ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ int d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spsi = nullptr;
|
||||
if (FAILED(hr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
|
||||
Reference in New Issue
Block a user