Allow Run to handle commandlines with spaces (#42016)

This better handles cases where commandlines might have embedded spaces.
For something like

```
C:\Program Files\PowerShell\7\pwsh.exe -c write-host dawg
```

we'll now see that `C:\Program` isn't a file, and we'll try to look at
`C:\Program Files\PowerShell\7\pwsh.exe` instead.

This code is pilfered from
https://github.com/microsoft/terminal/pull/12348 which fixed
https://github.com/microsoft/terminal/issues/12345. Terminal has great
code for normalizing a string into an executable and args, so why not
just use it here.

related to #41646
related to #41705 (but much more narrowly scoped)

----

I added some tests too.

drive-by fix: as I was adding tests, I added a helper for "make a change
to a page, and await the page's ItemsChanged". This removes a bunch of
`await 1s` calls, and brings the shell page tests from like, 7s to 500ms
This commit is contained in:
Mike Griese
2025-09-26 18:39:00 -05:00
committed by GitHub
parent 2b6c5d2cdd
commit c3398b0a01
7 changed files with 425 additions and 22 deletions

View File

@@ -92,7 +92,7 @@ internal sealed partial class FallbackExecuteItem : FallbackCommandItem, IDispos
return;
}
ShellHelpers.ParseExecutableAndArgs(searchText, out var exe, out var args);
ShellListPageHelpers.NormalizeCommandLineAndArgs(searchText, out var exe, out var args);
// Check for cancellation before file system operations
cancellationToken.ThrowIfCancellationRequested();