Skip to content

Commit 3609a92

Browse files
authored
feat: register agents to launchservices to allow launch from vscode (#308021)
* feat: register agents to launchservices to allow launch from vscode * chore: skip stable
1 parent 75f21d0 commit 3609a92

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • src/vs/code/electron-main

src/vs/code/electron-main/app.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { app, Details, GPUFeatureStatus, powerMonitor, protocol, session, Session, systemPreferences, WebFrameMain } from 'electron';
77
import { addUNCHostToAllowlist, disableUNCAccessRestrictions } from '../../base/node/unc.js';
88
import { validatedIpcMain } from '../../base/parts/ipc/electron-main/ipcMain.js';
9+
import { execFile } from 'child_process';
910
import { hostname, release } from 'os';
1011
import { initWindowsVersionInfo } from '../../base/node/windowsVersion.js';
1112
import { VSBuffer } from '../../base/common/buffer.js';
@@ -1729,5 +1730,25 @@ export class CodeApplication extends Disposable {
17291730
// Validate Device ID is up to date (delay this as it has shown significant perf impact)
17301731
// Refs: https://github.com/microsoft/vscode/issues/234064
17311732
validateDevDeviceId(this.stateService, this.logService);
1733+
1734+
// macOS: eagerly register the embedded app with Launch Services
1735+
this.registerEmbeddedAppWithLaunchServices();
1736+
}
1737+
1738+
private registerEmbeddedAppWithLaunchServices(): void {
1739+
if (!isMacintosh || (process as INodeProcess).isEmbeddedApp || !this.productService.embedded?.nameShort || this.productService.quality === 'stable') {
1740+
return;
1741+
}
1742+
1743+
// appRoot points to Contents/Resources/app on macOS
1744+
const embeddedAppPath = join(this.environmentMainService.appRoot, '..', '..', 'Applications', `${this.productService.embedded.nameShort}.app`);
1745+
const lsregister = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister';
1746+
this.logService.trace('Registering embedded app with Launch Services:', embeddedAppPath);
1747+
const child = execFile(lsregister, ['-f', embeddedAppPath], { timeout: 30_000 }, (error) => {
1748+
if (error) {
1749+
this.logService.error('Failed to register embedded app with Launch Services:', error.message);
1750+
}
1751+
});
1752+
child.unref();
17321753
}
17331754
}

0 commit comments

Comments
 (0)