Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/ActionMap.cpp (C++)

Code before:
    {
        // create an "unbound" command
        // { "command": "unbound", "keys": <keys> }
        const auto cmd{ make_self<Command>() };
        cmd->ActionAndArgs(make<ActionAndArgs>());
        cmd->RegisterKey(keys);
        AddAction(*cmd);
    }

    // Method Description:
    // - Add a new key binding
    // - If the key chord is already in use, the conflicting command is overwritten.
    // Arguments:
    // - keys: the key chord that is being bound
    // - action: the action that the keys are being bound to
    // Return Value:
    // - <none>
    void ActionMap::RegisterKeyBinding(Control::KeyChord keys, Model::ActionAndArgs action)
    {
        auto cmd{ make_self<Command>() };
        cmd->RegisterKey(keys);
        cmd->ActionAndArgs(action);
        AddAction(*cmd);
    }

    void ActionMap::AddSendInputAction(winrt::hstring name, winrt::hstring input)
    {
        auto newAction = winrt::make<ActionAndArgs>();
        newAction.Action(ShortcutAction::SendInput);
        auto sendInputArgs = winrt::make<SendInputArgs>(input);
        newAction.Args(sendInputArgs);
        auto cmd{ make_self<Command>() };
        cmd->ActionAndArgs(newAction);
        cmd->Name(name);
        AddAction(*cmd);
    }

    void ActionMap::_recursiveUpdateCommandKeybindingLabels()
    {
        const auto& commands{ _ExpandedCommandsCache };

        for (const auto& command : commands)
        {
            if (command.HasNestedCommands())
            {
                _recursiveUpdateCommandKeybindingLabels();
            }
            else
            {
                // If there's a keybinding that's bound to exactly this command,
                // then get the keychord and display it as a

Review comment (suggestion):
I tried to add this in TerminalPage::_HandleSaveTask,  the build errors from calling winrt::make<SendInputArgs>(input) from that project defeated me.

Code after:
                // without visualizing space and backspace
                //
                // This is exactly the body of SendInputArgs::GenerateName, but
                // with visualize_nonspace_control_codes instead of
                // visualize_control_codes, to make filtering in the suggestions
                // UI easier.

                const auto escapedInput = til::visualize_nonspace_control_codes(std::wstring{ inputString });
                const auto name = fmt::format(std::wstring_view(RS_(L"SendInputCommandKey")), escapedInput);
                copy->Name(winrt::hstring{ name });
            }

            return *copy;
        };

        // iterate over all the commands in all our actions...
        for (auto&& [name, command] : nameMap)
        {
            // If this is not a nested command, and it's a sendInput command...
            if (!command.HasNestedCommands() &&
                command.ActionAndArgs().Action() == ShortcutAction::SendInput)
            {
                // copy it into the results.
                results.Append(createInputAction(command));
            }
            // If this is nested...
            else if (command.HasNestedCommands())
            {
                // Look for any sendInput commands nested underneath us
                auto innerResults = _filterToSendInput(command.NestedCommands(), currentCommandline);

                if (innerResults.Size() > 0)
                {
                    // This command did have at least one sendInput under it

                    // Create a new Command, which is a copy of this Command,
                    // which only has SendInputs in it
                    winrt::com_ptr<implementation::Command> cmdImpl;
                    cmdImpl.copy_from(winrt::get_self<implementation::Command>(command));
                    auto copy = cmdImpl->Copy();
                    copy->NestedCommands(innerResults.GetView());

                    results.Append(*copy);
                }
            }
        }

        return results;
    }

    void ActionMap::AddSendInputAction(winrt::hstring name, winrt::hstring input, const Control::KeyChord keys)