Repository: microsoft/terminal (language: cpp)

Issue:
Command Palette and SXNUI wont match sendInput actions with a space in them
Add 

```json

        {
            "command": 
            {
                "action": "sendInput",
                "input": "git status"
            },
        },
```

to the settings. 


Then, go open the command palette for "git s". Note that the "Send input: git␣status" doesn't match, because '␣' != ' '
Backspaces we insert into a command for a `useCommandline` suggestion show up in the suggestions UI
v1.19 

1. add an action like
   ```json
        {
            "command": 
            {
                "action": "sendInput",
                "input": "git status"
            },
        },
   ```
2. Enable shell integration
3. type `git` at the prompt 
4. Do a `showSuggestions("source": [ "tasks", "commandHistory" ], "useCommandline": true)`.  The suggested task looks like

![image](https://github.com/microsoft/terminal/assets/18356694/49a3120b-4aba-400f-b8c7-76e13bde73b4)

The backspaces we inserted? Those show up in the name. They shouldn't. We can probably manually remove them, if we know the command didn't have a specific name set. 



Discussion / hints:

Fix patch:
diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp
index 220cd825565..7e480a33866 100644
--- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp
+++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp
@@ -6,6 +6,7 @@
 #include "ActionMap.h"
 #include "Command.h"
 #include "AllShortcutActions.h"
+#include <LibraryResources.h>
 
 #include "ActionMap.g.cpp"
 
@@ -964,17 +965,32 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
             cmdImpl.copy_from(winrt::get_self<implementation::Command>(command));
 
             const auto inArgs{ command.ActionAndArgs().Args().try_as<Model::SendInputArgs>() };
-
+            const auto inputString{ inArgs ? inArgs.Input() : L"" };
             auto args = winrt::make_self<SendInputArgs>(
                 winrt::hstring{ fmt::format(FMT_COMPILE(L"{:\x7f^{}}{}"),
                                             L"",
                                             numBackspaces,
-                                            (std::wstring_view)(inArgs ? inArgs.Input() : L"")) });
+                                            inputString) });
             Model::ActionAndArgs actionAndArgs{ ShortcutAction::SendInput, *args };
 
             auto copy = cmdImpl->Copy();
             copy->ActionAndArgs(actionAndArgs);
 
+            if (!copy->HasName())
+            {
+                // Here, we want to manually generate a send input name, but
+                // 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;
         };
 
diff --git a/src/inc/til/string.h b/src/inc/til/string.h
index fcb6905e282..5070ae472fe 100644
--- a/src/inc/til/string.h
+++ b/src/inc/til/string.h
@@ -24,6 +24,24 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
         }
         return str;
     }
+    // The same as the above, but it doesn't visualize BS nor SPC.
+    _TIL_INLINEPREFIX std::wstring visualize_nonspace_control_codes(std::wstring str) noexcept
+    {
+        for (auto& ch : str)
+        {
+            // NOT backspace!
+            if (ch < 0x20 && ch != 0x08)
+            {
+                ch += 0x2400;
+            }
+            // NOT space
+            else if (ch == 0x7f)
+            {
+                ch = 0x2421; // replace del with ␡
+            }
+        }
+        return str;
+    }
 
     _TIL_INLINEPREFIX std::wstring visualize_control_codes(std::wstring_view str)
     {


Test patch: