This makes command expansion the TerminalPage's responsibility, but it also only does it when the settings are reloaded. Lets try doing it every time the list of tabs changes

This commit is contained in:
Mike Griese
2020-08-05 12:20:04 -05:00
parent 2a8d4c51cb
commit 0719b425b3
4 changed files with 15 additions and 8 deletions

View File

@@ -731,9 +731,9 @@ std::string CascadiaSettings::_ApplyFirstRunChangesToSettingsTemplate(std::strin
// - <none>
void CascadiaSettings::_ExpandCommands()
{
winrt::TerminalApp::implementation::Command::ExpandCommands(_globals.GetCommands(),
_profiles,
_warnings);
// winrt::TerminalApp::implementation::Command::ExpandCommands(_globals.GetCommands(),
// _profiles,
// _warnings);
}
// Method Description:

View File

@@ -306,7 +306,7 @@ namespace winrt::TerminalApp::implementation
// Return Value:
// - <none>
void Command::ExpandCommands(std::unordered_map<winrt::hstring, winrt::TerminalApp::Command>& commands,
const std::vector<::TerminalApp::Profile>& profiles,
gsl::span<const ::TerminalApp::Profile> profiles,
std::vector<::TerminalApp::SettingsLoadWarnings>& warnings)
{
std::vector<winrt::hstring> commandsToRemove;
@@ -386,7 +386,7 @@ namespace winrt::TerminalApp::implementation
// - and empty vector if the command wasn't expandable, otherwise a list of
// the newly-created commands.
std::vector<winrt::TerminalApp::Command> Command::_expandCommand(winrt::com_ptr<Command> expandable,
const std::vector<::TerminalApp::Profile>& profiles,
gsl::span<const ::TerminalApp::Profile> profiles,
std::vector<::TerminalApp::SettingsLoadWarnings>& warnings)
{
std::vector<winrt::TerminalApp::Command> newCommands;

View File

@@ -46,7 +46,7 @@ namespace winrt::TerminalApp::implementation
std::vector<::TerminalApp::SettingsLoadWarnings>& warnings);
static void ExpandCommands(std::unordered_map<winrt::hstring, winrt::TerminalApp::Command>& commands,
const std::vector<::TerminalApp::Profile>& profiles,
gsl::span<const ::TerminalApp::Profile> profiles,
std::vector<::TerminalApp::SettingsLoadWarnings>& warnings);
static std::vector<::TerminalApp::SettingsLoadWarnings> LayerJson(std::unordered_map<winrt::hstring, winrt::TerminalApp::Command>& commands,
@@ -66,7 +66,7 @@ namespace winrt::TerminalApp::implementation
Windows::Foundation::Collections::IVector<TerminalApp::Command> _nestedCommandsView{ nullptr };
static std::vector<winrt::TerminalApp::Command> _expandCommand(winrt::com_ptr<Command> expandable,
const std::vector<::TerminalApp::Profile>& profiles,
gsl::span<const ::TerminalApp::Profile> profiles,
std::vector<::TerminalApp::SettingsLoadWarnings>& warnings);
void _createView();

View File

@@ -1982,9 +1982,16 @@ namespace winrt::TerminalApp::implementation
// - <none>
void TerminalPage::_UpdateCommandsForPalette()
{
std::vector<::TerminalApp::SettingsLoadWarnings> warnings;
std::unordered_map<winrt::hstring, winrt::TerminalApp::Command> copyOfCommands = _settings->GlobalSettings().GetCommands();
Command::ExpandCommands(copyOfCommands,
_settings->GetProfiles(),
warnings);
// Update the command palette when settings reload
auto commandsCollection = winrt::single_threaded_vector<winrt::TerminalApp::Command>();
for (auto& nameAndCommand : _settings->GlobalSettings().GetCommands())
for (auto& nameAndCommand : copyOfCommands)
{
commandsCollection.Append(nameAndCommand.second);
}