Default initialize a CmdPal mode (#7263)

Whoops, members are zero initialized in Debug builds but most likely not
in Release builds So, this PR adds a couple of default values to
`_currentMode` and its associated XAML strings to make cmdpal/ats work
deterministically on first use.  I also added a default value to
`_anchorKey` just to be safe.

Closes #7254
This commit is contained in:
Leon Liang 2020-08-12 16:25:50 -07:00 committed by GitHub
parent a02a29783e
commit 93ae6b6dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,6 +22,7 @@ using namespace winrt::Windows::Foundation::Collections;
namespace winrt::TerminalApp::implementation
{
CommandPalette::CommandPalette() :
_anchorKey{ VirtualKey::None },
_switcherStartIdx{ 0 }
{
InitializeComponent();
@ -30,6 +31,8 @@ namespace winrt::TerminalApp::implementation
_allCommands = winrt::single_threaded_vector<winrt::TerminalApp::Command>();
_allTabActions = winrt::single_threaded_vector<winrt::TerminalApp::Command>();
_switchToMode(CommandPaletteMode::ActionMode);
if (CommandPaletteShadow())
{
// Hook up the shadow on the command palette to the backdrop that
@ -389,23 +392,26 @@ namespace winrt::TerminalApp::implementation
{
_filteredActions.Append(action);
}
}
switch (_currentMode)
{
case CommandPaletteMode::TabSwitcherMode:
{
SearchBoxText(RS_(L"TabSwitcher_SearchBoxText"));
NoMatchesText(RS_(L"TabSwitcher_NoMatchesText"));
ControlName(RS_(L"TabSwitcherControlName"));
break;
}
case CommandPaletteMode::ActionMode:
default:
SearchBoxText(RS_(L"CommandPalette_SearchBox/PlaceholderText"));
NoMatchesText(RS_(L"CommandPalette_NoMatchesText/Text"));
ControlName(RS_(L"CommandPaletteControlName"));
break;
}
// Leaving this block of code outside the above if-statement
// guarantees that the correct text is shown for the mode
// whenever _switchToMode is called.
switch (_currentMode)
{
case CommandPaletteMode::TabSwitcherMode:
{
SearchBoxText(RS_(L"TabSwitcher_SearchBoxText"));
NoMatchesText(RS_(L"TabSwitcher_NoMatchesText"));
ControlName(RS_(L"TabSwitcherControlName"));
break;
}
case CommandPaletteMode::ActionMode:
default:
SearchBoxText(RS_(L"CommandPalette_SearchBox/PlaceholderText"));
NoMatchesText(RS_(L"CommandPalette_NoMatchesText/Text"));
ControlName(RS_(L"CommandPaletteControlName"));
break;
}
}