Skip to content

Commit 0b09f10

Browse files
committed
fix perserving start flags when using the restart option
1 parent 3a26d3c commit 0b09f10

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/OneWare.Core/Services/ApplicationStateService.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,16 @@ private void PerformRestart()
194194
{
195195
var executablePath = Environment.ProcessPath;
196196
var args = Environment.GetCommandLineArgs().Skip(1).ToArray();
197-
198-
// Remove last argument if it's not a flag
199-
if (args.Length > 0)
200-
{
201-
var lastArg = args.Last();
202197

203-
if (!lastArg.StartsWith("-", StringComparison.Ordinal))
204-
{
205-
args = args.Take(args.Length - 1).ToArray();
206-
}
198+
// Do not repeat a positional file, directory, or URI launch action after restarting.
199+
// Preserve a trailing option value, which is also a non-flag argument.
200+
if (args.Length > 0 &&
201+
!args[^1].StartsWith("-", StringComparison.Ordinal) &&
202+
(args.Length == 1 || !args[^2].StartsWith("-", StringComparison.Ordinal)))
203+
{
204+
args = args[..^1];
207205
}
208-
206+
209207
if (string.IsNullOrEmpty(executablePath))
210208
{
211209
ContainerLocator.Container.Resolve<ILogger>()?.Error("Cannot restart: executable path not found");

0 commit comments

Comments
 (0)