|
6 | 6 | import { app, Details, GPUFeatureStatus, powerMonitor, protocol, session, Session, systemPreferences, WebFrameMain } from 'electron'; |
7 | 7 | import { addUNCHostToAllowlist, disableUNCAccessRestrictions } from '../../base/node/unc.js'; |
8 | 8 | import { validatedIpcMain } from '../../base/parts/ipc/electron-main/ipcMain.js'; |
| 9 | +import { execFile } from 'child_process'; |
9 | 10 | import { hostname, release } from 'os'; |
10 | 11 | import { initWindowsVersionInfo } from '../../base/node/windowsVersion.js'; |
11 | 12 | import { VSBuffer } from '../../base/common/buffer.js'; |
@@ -1729,5 +1730,25 @@ export class CodeApplication extends Disposable { |
1729 | 1730 | // Validate Device ID is up to date (delay this as it has shown significant perf impact) |
1730 | 1731 | // Refs: https://github.com/microsoft/vscode/issues/234064 |
1731 | 1732 | 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(); |
1732 | 1753 | } |
1733 | 1754 | } |
0 commit comments