From 5052e6436bb9c3f4c9d83d76ab378a0e2087edd1 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 8 Jul 2020 17:21:02 -0500 Subject: [PATCH] Revert "This was a failure" This reverts commit 93d31c250d4d45f2f6bec72e8f66e8728e4ed706. --- .../LocalTests_TerminalApp/SettingsTests.cpp | 3 - src/cascadia/TerminalApp/Command.cpp | 105 ++++++------------ 2 files changed, 35 insertions(+), 73 deletions(-) diff --git a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp index de6630d682..d8c32a19af 100644 --- a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp @@ -3000,9 +3000,6 @@ namespace TerminalAppLocalTests VerifyParseSucceeded(settingsJson); CascadiaSettings settings{}; settings._ParseJsonString(settingsJson, false); - - DebugBreak(); - settings.LayerJson(settings._userSettings); VERIFY_ARE_EQUAL(0u, settings._warnings.size()); diff --git a/src/cascadia/TerminalApp/Command.cpp b/src/cascadia/TerminalApp/Command.cpp index 2a640203e6..d82d7a3681 100644 --- a/src/cascadia/TerminalApp/Command.cpp +++ b/src/cascadia/TerminalApp/Command.cpp @@ -121,53 +121,53 @@ namespace winrt::TerminalApp::implementation // - the newly constructed Command object. winrt::com_ptr Command::FromJson(const Json::Value& json, std::vector<::TerminalApp::SettingsLoadWarnings>& warnings, - const bool /*postExpansion*/) + const bool postExpansion) { auto result = winrt::make_self(); bool iterable = false; bool nested = false; - // if (!postExpansion) - // { - if (const auto iterateOnJson{ json[JsonKey(IterateOnKey)] }) + if (!postExpansion) { - auto s = iterateOnJson.asString(); - if (s == IterateOnProfilesValue) + if (const auto iterateOnJson{ json[JsonKey(IterateOnKey)] }) { - result->_IterateOn = ExpandCommandType::Profiles; - iterable = true; + auto s = iterateOnJson.asString(); + if (s == IterateOnProfilesValue) + { + result->_IterateOn = ExpandCommandType::Profiles; + iterable = true; + } } } - // } - // // For iterable commands, we'll make another pass at parsing them once - // // the json is patched. So ignore parsing sub-commands for now. Commands - // // will only be marked iterable on the first pass. - // if (!iterable) - // { - if (const auto nestedCommandsJson{ json[JsonKey(CommandsKey)] }) + // For iterable commands, we'll make another pass at parsing them once + // the json is patched. So ignore parsing sub-commands for now. Commands + // will only be marked iterable on the first pass. + if (!iterable) { - auto nestedWarnings = Command::LayerJson(result->_subcommands, nestedCommandsJson); - // It's possible that the nested commands have some warnings - warnings.insert(warnings.end(), nestedWarnings.begin(), nestedWarnings.end()); - - // Add all the commands we've parsed to the observable vector we - // have, so we can access them in XAML. - for (auto& nameAndCommand : result->_subcommands) + if (const auto nestedCommandsJson{ json[JsonKey(CommandsKey)] }) { - auto command = nameAndCommand.second; - result->_nestedCommandsView.Append(command); - } - nested = true; - } + auto nestedWarnings = Command::LayerJson(result->_subcommands, nestedCommandsJson); + // It's possible that the nested commands have some warnings + warnings.insert(warnings.end(), nestedWarnings.begin(), nestedWarnings.end()); - // TODO: else if (hasKey(CommandKey) ) - // { - // // { name: "foo", commands: null } will land in this case, which - // // should also be used for unbinding. - // return nullptr; - // } - // } + // Add all the commands we've parsed to the observable vector we + // have, so we can access them in XAML. + for (auto& nameAndCommand : result->_subcommands) + { + auto command = nameAndCommand.second; + result->_nestedCommandsView.Append(command); + } + nested = true; + } + + // TODO: else if (hasKey(CommandKey) ) + // { + // // { name: "foo", commands: null } will land in this case, which + // // should also be used for unbinding. + // return nullptr; + // } + } // TODO GH#6644: iconPath not implemented quite yet. Can't seem to get // the binding quite right. Additionally, do we want it to be an image, @@ -342,42 +342,7 @@ namespace winrt::TerminalApp::implementation { std::vector newCommands; - // //////////////////////////////////////////////////////////////////////// - // if (!expandable->_subcommands.empty()) - // { - // // Blatantly copied from CascadiaSettings::_ExpandCommands - - // std::vector commandsToRemove; - // std::vector commandsToAdd; - // // First, collect up all the commands that need replacing. - // for (auto nameAndCmd : expandable->_subcommands) - // { - // winrt::com_ptr cmd; - // cmd.copy_from(winrt::get_self(nameAndCmd.second)); - - // auto newCommands = winrt::TerminalApp::implementation::Command::ExpandCommand(cmd, profiles, warnings); - // if (newCommands.size() > 0) - // { - // commandsToRemove.push_back(nameAndCmd.first); - // commandsToAdd.insert(commandsToAdd.end(), newCommands.begin(), newCommands.end()); - // } - // } - - // // Second, remove all the commands that need to be removed. - // for (auto& name : commandsToRemove) - // { - // expandable->_subcommands.erase(name); - // } - - // // Finally, add all the new commands. - // for (auto& cmd : commandsToAdd) - // { - // expandable->_subcommands.insert_or_assign(cmd.Name(), cmd); - // } - // } - // //////////////////////////////////////////////////////////////////////// - - if (expandable->_subcommands.empty() && expandable->_IterateOn == ExpandCommandType::None) + if (expandable->_IterateOn == ExpandCommandType::None) { return newCommands; }