Teach command palette to ignore case when sorting items (#8432)

Closes #8430
This commit is contained in:
Don-Vito 2020-11-30 22:19:49 +02:00 committed by GitHub
parent 90316be322
commit 2a79ba2fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View file

@ -2835,3 +2835,4 @@ BBBBBCCC
abcd
LPMINMAXINFO
MINMAXINFO
lstrcmpi

View file

@ -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));
}
}
}

View file

@ -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;