-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix command line relative path resolution #1857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bd37e3f
88efbee
b3ee2cf
2777547
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,8 +126,19 @@ protected override void OnStartup(StartupEventArgs e) | |
| RunListener(e); | ||
|
|
||
| // First instance: run and preview this file | ||
| if (e.Args.Any() && (Directory.Exists(e.Args.First()) || File.Exists(e.Args.First()))) | ||
| PipeServerManager.SendMessage(PipeMessages.Toggle, e.Args.First()); | ||
| if (e.Args.Any()) | ||
| { | ||
| try | ||
| { | ||
| var path = Path.GetFullPath(e.Args.First()); | ||
| if (Directory.Exists(path) || File.Exists(path)) | ||
| PipeServerManager.SendMessage(PipeMessages.Toggle, path); | ||
| } | ||
| catch | ||
| { | ||
| // Invalid path, ignore | ||
| } | ||
| } | ||
|
|
||
| // Exception handling events which are not caught in the Task thread | ||
| TaskScheduler.UnobservedTaskException += (_, e) => | ||
|
|
@@ -290,16 +301,26 @@ private bool EnsureFirstInstance(string[] args) | |
| return true; | ||
|
|
||
| // Second instance: preview this file | ||
| if (args.Any() && (Directory.Exists(args.First()) || File.Exists(args.First()))) | ||
| if (args.Any()) | ||
| { | ||
| PipeServerManager.SendMessage(PipeMessages.Toggle, args.First(), [.. args.Skip(1)]); | ||
| try | ||
| { | ||
| var path = Path.GetFullPath(args.First()); | ||
| if (Directory.Exists(path) || File.Exists(path)) | ||
| { | ||
| PipeServerManager.SendMessage(PipeMessages.Toggle, path, [.. args.Skip(1)]); | ||
| return false; | ||
| } | ||
| } | ||
| catch | ||
| { | ||
| // Invalid path, continue to show duplicate message | ||
| } | ||
|
Comment on lines
+315
to
+318
|
||
| } | ||
|
|
||
| // Second instance: duplicate | ||
| else | ||
| { | ||
| MessageBox.Show(TranslationHelper.Get("APP_SECOND_TEXT"), TranslationHelper.Get("APP_SECOND"), | ||
| MessageBoxButton.OK, MessageBoxImage.Information); | ||
| } | ||
| MessageBox.Show(TranslationHelper.Get("APP_SECOND_TEXT"), TranslationHelper.Get("APP_SECOND"), | ||
| MessageBoxButton.OK, MessageBoxImage.Information); | ||
|
Comment on lines
321
to
+323
|
||
|
|
||
| return false; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block is too broad and catches all exceptions. According to the PR description, specific exceptions should be caught: ArgumentException, SecurityException, NotSupportedException, and PathTooLongException. The current implementation could silently swallow unexpected exceptions that should be handled or logged differently. Consider using a filtered catch clause to only handle path-related exceptions.