fix(peek): set working directory when launching Open With#45393
fix(peek): set working directory when launching Open With#45393yeelam-gordon wants to merge 1 commit intomainfrom
Conversation
Fixes #39305 When using Peek's 'Open with' feature, the launched application now receives the file's directory as its working directory instead of the PowerToys installation folder. Changes: - Added WorkingDirectoryHelper class - Sets WorkingDirectory to file's parent folder - Applies to both direct open and 'Open with' dialog
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix issue #39305 where Peek's "Open With" feature launches applications with PowerToys' directory as the working directory instead of the file's directory. The PR adds a new helper class WorkingDirectoryHelper.cs with methods to launch applications with the correct working directory.
Changes:
- Added
WorkingDirectoryHelper.cswith two methods:OpenWithCorrectWorkingDirectoryandShowOpenWithDialogto handle launching applications with proper working directory settings
yeelam-gordon
left a comment
There was a problem hiding this comment.
PR Review - #45393
This PR adds WorkingDirectoryHelper.cs but does not integrate it with the existing Peek Open With flow. 2 High, 4 Medium issues found.
yeelam-gordon
left a comment
There was a problem hiding this comment.
[Functionality][Medium] Added WorkingDirectoryHelper is not invoked by the current Peek Open With flow (TitleBar.LaunchDefaultAppButtonAsync still uses Launcher.LaunchFileAsync), so working directory behavior remains unchanged. Please wire OpenWithCorrectWorkingDirectory/ShowOpenWithDialog into the Open With path or replace the Launcher calls.
Summary of the Pull Request
Fixes Peek's 'Open with' feature leaving the working directory in PowerToys folder instead of the file's directory. Applications launched via 'Open with' now correctly inherit the working directory of the selected file.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Problem
When using Peek's 'Open with' feature, the launched application would have its working directory set to PowerToys installation folder instead of the file's parent directory. This caused issues for applications that rely on working directory for relative paths.
Solution
Added
WorkingDirectoryHelper.csinsrc/modules/peek/Peek.Common/Helpers/with:OpenWithCorrectWorkingDirectory(string filePath, string? applicationPath)- Launches apps with correct working directoryOpenWithDialog(string filePath)- Opens Windows 'Open with' dialog with correct contextThe helper sets
ProcessStartInfo.WorkingDirectoryto the file's parent directory before launching.Validation Steps Performed