Teach command palette to ignore case when sorting items (#8432)
Closes #8430
This commit is contained in:
parent
90316be322
commit
2a79ba2fd3
|
@ -2835,3 +2835,4 @@ BBBBBCCC
|
|||
abcd
|
||||
LPMINMAXINFO
|
||||
MINMAXINFO
|
||||
lstrcmpi
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace TerminalAppLocalTests
|
|||
TEST_METHOD(VerifyHighlighting);
|
||||
TEST_METHOD(VerifyWeight);
|
||||
TEST_METHOD(VerifyCompare);
|
||||
TEST_METHOD(VerifyCompareIgnoreCase);
|
||||
};
|
||||
|
||||
void FilteredCommandTests::VerifyHighlighting()
|
||||
|
@ -268,4 +269,38 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_FALSE(winrt::TerminalApp::implementation::FilteredCommand::Compare(*filteredCommand, *filteredCommand2));
|
||||
}
|
||||
}
|
||||
|
||||
void FilteredCommandTests::VerifyCompareIgnoreCase()
|
||||
{
|
||||
const std::string settingsJson{ R"(
|
||||
{
|
||||
"defaultProfile": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
|
||||
"profiles": [
|
||||
{
|
||||
"name": "profile0",
|
||||
"guid": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
|
||||
"historySize": 1,
|
||||
"commandline": "cmd.exe"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{ "keys": ["ctrl+a"], "command": { "action": "splitPane", "split": "vertical" }, "name": "a" },
|
||||
{ "keys": ["ctrl+b"], "command": { "action": "splitPane", "split": "horizontal" }, "name": "B" }
|
||||
]
|
||||
})" };
|
||||
|
||||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
const auto commands = settings.GlobalSettings().Commands();
|
||||
VERIFY_ARE_EQUAL(2u, commands.Size());
|
||||
|
||||
const auto command = commands.Lookup(L"a");
|
||||
const auto command2 = commands.Lookup(L"B");
|
||||
{
|
||||
const auto filteredCommand = winrt::make_self<winrt::TerminalApp::implementation::FilteredCommand>(command);
|
||||
const auto filteredCommand2 = winrt::make_self<winrt::TerminalApp::implementation::FilteredCommand>(command2);
|
||||
|
||||
VERIFY_ARE_EQUAL(filteredCommand->Weight(), filteredCommand2->Weight());
|
||||
VERIFY_IS_TRUE(winrt::TerminalApp::implementation::FilteredCommand::Compare(*filteredCommand, *filteredCommand2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
std::wstring_view firstName{ first.Command().Name() };
|
||||
std::wstring_view secondName{ second.Command().Name() };
|
||||
return firstName.compare(secondName) < 0;
|
||||
return lstrcmpi(firstName.data(), secondName.data()) < 0;
|
||||
}
|
||||
|
||||
return firstWeight > secondWeight;
|
||||
|
|
Loading…
Reference in a new issue