@@ -113,13 +113,14 @@ namespace winrt::TerminalApp::implementation
113
113
114
114
_settings = settings;
115
115
116
- // Make sure to _UpdateCommandsForPalette before
117
- // _RefreshUIForSettingsReload. _UpdateCommandsForPalette will make
118
- // sure the KeyChordText of Commands is updated, which needs to
119
- // happen before the Settings UI is reloaded and tries to re-read
120
- // those values.
121
- _UpdateCommandsForPalette ();
122
- CommandPalette ().SetActionMap (_settings.ActionMap ());
116
+ // Make sure to call SetCommands before _RefreshUIForSettingsReload.
117
+ // SetCommands will make sure the KeyChordText of Commands is updated, which needs
118
+ // to happen before the Settings UI is reloaded and tries to re-read those values.
119
+ if (const auto p = CommandPaletteElement ())
120
+ {
121
+ p.SetCommands (_settings.GlobalSettings ().ActionMap ().ExpandedCommands ());
122
+ p.SetActionMap (_settings.ActionMap ());
123
+ }
123
124
124
125
if (needRefreshUI)
125
126
{
@@ -256,20 +257,6 @@ namespace winrt::TerminalApp::implementation
256
257
257
258
_UpdateTabWidthMode ();
258
259
259
- // When the visibility of the command palette changes to "collapsed",
260
- // the palette has been closed. Toss focus back to the currently active
261
- // control.
262
- CommandPalette ().RegisterPropertyChangedCallback (UIElement::VisibilityProperty (), [this ](auto &&, auto &&) {
263
- if (CommandPalette ().Visibility () == Visibility::Collapsed)
264
- {
265
- _FocusActiveControl (nullptr , nullptr );
266
- }
267
- });
268
- CommandPalette ().DispatchCommandRequested ({ this , &TerminalPage::_OnDispatchCommandRequested });
269
- CommandPalette ().CommandLineExecutionRequested ({ this , &TerminalPage::_OnCommandLineExecutionRequested });
270
- CommandPalette ().SwitchToTabRequested ({ this , &TerminalPage::_OnSwitchToTabRequested });
271
- CommandPalette ().PreviewAction ({ this , &TerminalPage::_PreviewActionHandler });
272
-
273
260
// Settings AllowDependentAnimations will affect whether animations are
274
261
// enabled application-wide, so we don't need to check it each time we
275
262
// want to create an animation.
@@ -685,7 +672,6 @@ namespace winrt::TerminalApp::implementation
685
672
// Notes link, send feedback link and privacy policy link.
686
673
void TerminalPage::_ShowAboutDialog ()
687
674
{
688
- AboutDialog ().QueueUpdateCheck ();
689
675
_ShowDialogHelper (L" AboutDialog" );
690
676
}
691
677
@@ -1334,8 +1320,9 @@ namespace winrt::TerminalApp::implementation
1334
1320
void TerminalPage::_CommandPaletteButtonOnClick (const IInspectable&,
1335
1321
const RoutedEventArgs&)
1336
1322
{
1337
- CommandPalette ().EnableCommandPaletteMode (CommandPaletteLaunchMode::Action);
1338
- CommandPalette ().Visibility (Visibility::Visible);
1323
+ auto p = LoadCommandPalette ();
1324
+ p.EnableCommandPaletteMode (CommandPaletteLaunchMode::Action);
1325
+ p.Visibility (Visibility::Visible);
1339
1326
}
1340
1327
1341
1328
// Method Description:
@@ -1351,7 +1338,7 @@ namespace winrt::TerminalApp::implementation
1351
1338
}
1352
1339
1353
1340
// Method Description:
1354
- // - Called when the users pressed keyBindings while CommandPalette is open.
1341
+ // - Called when the users pressed keyBindings while CommandPaletteElement is open.
1355
1342
// - As of GH#8480, this is also bound to the TabRowControl's KeyUp event.
1356
1343
// That should only fire when focus is in the tab row, which is hard to
1357
1344
// do. Notably, that's possible:
@@ -1422,7 +1409,7 @@ namespace winrt::TerminalApp::implementation
1422
1409
return ;
1423
1410
}
1424
1411
1425
- if (const auto p = CommandPalette (); p.Visibility () == Visibility::Visible && cmd.ActionAndArgs ().Action () != ShortcutAction::ToggleCommandPalette)
1412
+ if (const auto p = CommandPaletteElement (); p.Visibility () == Visibility::Visible && cmd.ActionAndArgs ().Action () != ShortcutAction::ToggleCommandPalette)
1426
1413
{
1427
1414
p.Visibility (Visibility::Collapsed);
1428
1415
}
@@ -1746,6 +1733,40 @@ namespace winrt::TerminalApp::implementation
1746
1733
}
1747
1734
return nullptr ;
1748
1735
}
1736
+
1737
+ CommandPalette TerminalPage::LoadCommandPalette ()
1738
+ {
1739
+ if (const auto p = CommandPaletteElement ())
1740
+ {
1741
+ return p;
1742
+ }
1743
+
1744
+ return _loadCommandPaletteSlowPath ();
1745
+ }
1746
+
1747
+ CommandPalette TerminalPage::_loadCommandPaletteSlowPath ()
1748
+ {
1749
+ const auto p = FindName (L" CommandPaletteElement" ).as <CommandPalette>();
1750
+
1751
+ p.SetCommands (_settings.GlobalSettings ().ActionMap ().ExpandedCommands ());
1752
+ p.SetActionMap (_settings.ActionMap ());
1753
+
1754
+ // When the visibility of the command palette changes to "collapsed",
1755
+ // the palette has been closed. Toss focus back to the currently active control.
1756
+ p.RegisterPropertyChangedCallback (UIElement::VisibilityProperty (), [this ](auto &&, auto &&) {
1757
+ if (CommandPaletteElement ().Visibility () == Visibility::Collapsed)
1758
+ {
1759
+ _FocusActiveControl (nullptr , nullptr );
1760
+ }
1761
+ });
1762
+ p.DispatchCommandRequested ({ this , &TerminalPage::_OnDispatchCommandRequested });
1763
+ p.CommandLineExecutionRequested ({ this , &TerminalPage::_OnCommandLineExecutionRequested });
1764
+ p.SwitchToTabRequested ({ this , &TerminalPage::_OnSwitchToTabRequested });
1765
+ p.PreviewAction ({ this , &TerminalPage::_PreviewActionHandler });
1766
+
1767
+ return p;
1768
+ }
1769
+
1749
1770
// Method Description:
1750
1771
// - Warn the user that they are about to close all open windows, then
1751
1772
// signal that we want to close everything.
@@ -3141,21 +3162,6 @@ namespace winrt::TerminalApp::implementation
3141
3162
}
3142
3163
}
3143
3164
3144
- // Method Description:
3145
- // - Repopulates the list of commands in the command palette with the
3146
- // current commands in the settings. Also updates the keybinding labels to
3147
- // reflect any matching keybindings.
3148
- // Arguments:
3149
- // - <none>
3150
- // Return Value:
3151
- // - <none>
3152
- void TerminalPage::_UpdateCommandsForPalette ()
3153
- {
3154
- // Update the command palette when settings reload
3155
- const auto & expanded{ _settings.GlobalSettings ().ActionMap ().ExpandedCommands () };
3156
- CommandPalette ().SetCommands (expanded);
3157
- }
3158
-
3159
3165
// Method Description:
3160
3166
// - Sets the initial actions to process on startup. We'll make a copy of
3161
3167
// this list, and process these actions when we're loaded.
@@ -4827,5 +4833,4 @@ namespace winrt::TerminalApp::implementation
4827
4833
// _RemoveTab will make sure to null out the _stashed.draggedTab
4828
4834
_RemoveTab (*_stashed.draggedTab );
4829
4835
}
4830
-
4831
4836
}
0 commit comments