-
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
Conversation
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
…ling" This reverts commit b3ee2cf.
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.
Pull request overview
This PR fixes command line relative path resolution by converting relative paths to absolute paths before checking file/directory existence. Previously, quicklook 1.txt only worked when invoked from the QuickLook installation directory.
Changes:
- Added
Path.GetFullPath()call to convert relative paths to absolute before existence checks - Wrapped path resolution in try-catch blocks to handle invalid paths gracefully
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| catch | ||
| { | ||
| // Invalid path, ignore | ||
| } |
Copilot
AI
Jan 19, 2026
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.
| // 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); |
Copilot
AI
Jan 19, 2026
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 control flow is incorrect. The duplicate message MessageBox will now always be shown, even when a valid file path is successfully processed. Previously, the else clause ensured the message was only shown when no arguments were provided or the path was invalid. This breaks the second instance behavior - when a user opens a file from a second instance, they will see both the file preview AND the duplicate instance message. The MessageBox call on lines 322-323 should only execute when args are empty or when the path is invalid/doesn't exist.
| catch | ||
| { | ||
| // Invalid path, continue to show duplicate message | ||
| } |
Copilot
AI
Jan 19, 2026
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.
Command line arguments with relative paths (e.g.,
quicklook 1.txt) failed when invoked from directories other than the QuickLook installation directory.File.Exists()andDirectory.Exists()were checking paths against the application's working directory instead of the shell's current directory.Changes
Path.GetFullPath()before existence checks in both first and second instance code pathsArgumentException,SecurityException,NotSupportedException, andPathTooLongExceptionAbsolute paths continue to work unchanged. Invalid paths are silently ignored.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.