feat: support opening folders on Mac with vscode#302413
feat: support opening folders on Mac with vscode#302413
Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
There was a problem hiding this comment.
Pull request overview
Adds macOS-only commands to install/uninstall a Finder “Quick Action / Services” workflow that opens selected files/folders in VS Code via open -a ..., integrating with the existing Shell Command action area.
Changes:
- Extend
ICommonNativeHostServicewithinstallFinderAction/uninstallFinderAction. - Implement Finder workflow generation/removal in the Electron main native host service.
- Add and register new workbench actions (macOS only) and update test stubs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/native/common/native.ts | Adds new native host API methods for Finder action install/uninstall. |
| src/vs/platform/native/electron-main/nativeHostMainService.ts | Implements workflow bundle creation/removal under ~/Library/Services. |
| src/vs/workbench/electron-browser/actions/installActions.ts | Adds new command palette actions to invoke the native host APIs. |
| src/vs/workbench/electron-browser/desktop.contribution.ts | Registers the new actions on macOS. |
| src/vs/workbench/test/electron-browser/workbenchTestServices.ts | Updates native host test stub to match the new interface. |
Comments suppressed due to low confidence (1)
src/vs/platform/native/electron-main/nativeHostMainService.ts:692
productService.nameLongis embedded into thedocument.wflowXML command string without XML escaping. If it ever contains&,<,>, or", the workflow file will be invalid. Please XML-escape interpolated values before writing the plist.
'\t\t\t\t<dict>',
'\t\t\t\t\t<key>COMMAND_STRING</key>',
`\t\t\t\t\t<string>open -a "${appName}" "$@"</string>`,
'\t\t\t\t\t<key>CheckedForUserDefaultShell</key>',
bpasero
left a comment
There was a problem hiding this comment.
This is nice, but can you clean the diff to be minimal, I find it hard to review, there seems to be unrelated changes around import sort order and some on did blur event that moved.
|
@deepak1556 adding you, maybe you have thoughts as well how to do this on install time or from our existing info.plist file where we register handlers for common file types. |
Add 'Install Open with Code in Finder' and 'Uninstall Open with Code from Finder'
commands under the Shell Command category (macOS only).
These commands install/uninstall a macOS Automator Quick Action workflow to
~/Library/Services/ that adds an 'Open with {productName}' entry to the Finder
right-click context menu (Quick Actions/Services). The workflow runs
'open -a "{appName}" "$@"' to open selected files/folders in VS Code.
Each VS Code build (Stable, Insiders, OSS) creates a distinctly-named workflow,
so multiple installations coexist without conflict.
8402a12 to
ed0f40a
Compare
|
@bpasero thank you! minimized diffs and removed unrelated changes (which came from background session applying changes without my consent, I believe) |
deepak1556
left a comment
There was a problem hiding this comment.
Could we have a native module handle the service callback, the module can register itself as a service provider, the service provider can also implement menu validation that would either enable or disable the menu. This also has the nice benefit of having the service menu declaration as part of our app bundles info.plist.
|
@deepak1556 do I understand it correctly that the native approach would involve these todos?
|
|
1, 2 and 3 correct
|
Add Install 'Open with Code' in Finder and Uninstall 'Open with Code' from Finder commands under the Shell Command category (macOS only).
These commands install/uninstall a macOS Automator Quick Action workflow to `~/Library/Services/` that adds an 'Open with {productName}' entry to the Finder right-click context menu (Quick Actions / Services).
The workflow runs `open -a "{appName}" "$@"` to open selected files/folders in VS Code.
Each VS Code build (Stable, Insiders, OSS) creates a distinctly-named workflow, so multiple installations coexist without conflict.
How to use
Files changed
Demo
CleanShot.2026-03-17.at.12.08.33.mp4