Repository: microsoft/terminal (language: cpp)

Issue:
--profile: 1 required TEST missing
### Windows Terminal version

Windows Terminal Version: 1.13.11432.0

### Windows build number

Microsoft Windows [Version 10.0.22000.708]

### Other Software

_No response_

### Steps to reproduce

1. Create profile named "u"
2. Run wt -p "u"; nt -p "u"
3. Error appear.
4. "--profile: 1 required TEST missing"

### Expected Behavior

New windows terminal is created with two tabs

### Actual Behavior

The error pops up and Windows Terminal never opens.
Screenshot of the error  https://prnt.sc/y4Hi3Uir5as9
I think profile name is too short(one sign). Profile name with more than one sign works like a charm.


Discussion / hints:
@Andrew1988123123 that's an interesting find! If you add a space between first profile name and semicolon then it works.

Sample output with `wt -p "u"; nt -p "u"`

![wt_error](https://user-images.githubusercontent.com/3933920/173211316-d881b262-57c0-49f1-a4be-7a186852b3fb.png)

and `wt -p "u" ; nt -p "u"`

![image](https://user-images.githubusercontent.com/3933920/173211276-06b28cec-5bb1-4289-a432-7a6a67bff184.png)


This works with empty names also, `"name": null` , so `wt -p "" ; nt -p ""` would open two tabs. Maybe schema should be updated from `null` to `string`
Huh. Maybe I'm splitting things poorly on the `;`, it's really weird that adding a space would fix this. Command-line parsing is hard 🙃
No big deal. I just have to remember adding space before `;` . Even documentation say so.

Fix patch:
diff --git a/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp b/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp
index ff1f2e7d368..3d0837d0a64 100644
--- a/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp
+++ b/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp
@@ -349,6 +349,21 @@ namespace TerminalAppLocalTests
             VERIFY_ARE_EQUAL("wt.exe", commandlines.at(3).Args().at(0));
             VERIFY_ARE_EQUAL("baz", commandlines.at(3).Args().at(1));
         }
+        {
+            std::vector<const wchar_t*> rawCommands{ L"wt.exe", L"-p", L"u;", L"nt", L"-p", L"u" };
+
+            auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands);
+            VERIFY_ARE_EQUAL(2u, commandlines.size());
+            VERIFY_ARE_EQUAL(3u, commandlines.at(0).Argc());
+            VERIFY_ARE_EQUAL("wt.exe", commandlines.at(0).Args().at(0));
+            VERIFY_ARE_EQUAL("-p", commandlines.at(0).Args().at(1));
+            VERIFY_ARE_EQUAL("u", commandlines.at(0).Args().at(2));
+            VERIFY_ARE_EQUAL(4u, commandlines.at(1).Argc());
+            VERIFY_ARE_EQUAL("wt.exe", commandlines.at(1).Args().at(0));
+            VERIFY_ARE_EQUAL("nt", commandlines.at(1).Args().at(1));
+            VERIFY_ARE_EQUAL("-p", commandlines.at(1).Args().at(2));
+            VERIFY_ARE_EQUAL("u", commandlines.at(1).Args().at(3));
+        }
     }
 
     void CommandlineTest::TestEscapeDelimiters()
diff --git a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp
index fccc675db34..6e24cc54485 100644
--- a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp
+++ b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp
@@ -809,7 +809,11 @@ void AppCommandlineArgs::_addCommandsForArg(std::vector<Commandline>& commands,
         else
         {
             // Harder case: There was a match.
-            const auto matchedFirstChar = match.position(0) == 0;
+
+            // Regex will include the last character of the string before the delimiter. (see _commandDelimiterRegex)
+            // If the match was at the beginning of the string then there is no last character
+            // so we can use the length of the match to determine if it was at the beginning.
+            const auto matchedFirstChar = match[0].length() == 1;
             // If the match was at the beginning of the string, then the
             // next arg should be "", since there was no content before the
             // delimiter. Otherwise, add one, since the regex will include


Test patch: