66import { app , ipcMain as ipc , systemPreferences , shell , Event , contentTracing , protocol , powerMonitor , IpcMainEvent } from 'electron' ;
77import { IProcessEnvironment , isWindows , isMacintosh } from 'vs/base/common/platform' ;
88import { WindowsManager } from 'vs/code/electron-main/windows' ;
9- import { IWindowsService , OpenContext , IWindowOpenable } from 'vs/platform/windows/common/windows' ;
9+ import { OpenContext , IWindowOpenable } from 'vs/platform/windows/common/windows' ;
1010import { ActiveWindowManager } from 'vs/platform/windows/node/windows' ;
11- import { WindowsChannel } from 'vs/platform/windows/common/windowsIpc' ;
12- import { LegacyWindowsMainService } from 'vs/platform/windows/electron-main/legacyWindowsMainService' ;
1311import { ILifecycleMainService , LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService' ;
1412import { getShellEnvironment } from 'vs/code/node/shellEnv' ;
1513import { IUpdateService } from 'vs/platform/update/common/update' ;
@@ -79,6 +77,7 @@ import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/ext
7977import { IElectronService } from 'vs/platform/electron/node/electron' ;
8078import { ElectronMainService } from 'vs/platform/electron/electron-main/electronMainService' ;
8179import { ISharedProcessMainService , SharedProcessMainService } from 'vs/platform/ipc/electron-main/sharedProcessMainService' ;
80+ import { assign } from 'vs/base/common/objects' ;
8281
8382export class CodeApplication extends Disposable {
8483
@@ -451,7 +450,6 @@ export class CodeApplication extends Disposable {
451450
452451 services . set ( IWindowsMainService , new SyncDescriptor ( WindowsManager , [ machineId , this . userEnv ] ) ) ;
453452 services . set ( ISharedProcessMainService , new SyncDescriptor ( SharedProcessMainService , [ sharedProcess ] ) ) ;
454- services . set ( IWindowsService , new SyncDescriptor ( LegacyWindowsMainService ) ) ;
455453 services . set ( ILaunchMainService , new SyncDescriptor ( LaunchMainService ) ) ;
456454
457455 const diagnosticsChannel = getDelayedChannel ( sharedProcessClient . then ( client => client . getChannel ( 'diagnostics' ) ) ) ;
@@ -557,10 +555,6 @@ export class CodeApplication extends Disposable {
557555 const workspacesChannel = new WorkspacesChannel ( workspacesMainService , accessor . get ( IWindowsMainService ) ) ;
558556 electronIpcServer . registerChannel ( 'workspaces' , workspacesChannel ) ;
559557
560- const windowsService = accessor . get ( IWindowsService ) ;
561- const windowsChannel = new WindowsChannel ( windowsService ) ;
562- electronIpcServer . registerChannel ( 'windows' , windowsChannel ) ;
563-
564558 const menubarService = accessor . get ( IMenubarService ) ;
565559 const menubarChannel = createChannelReceiver ( menubarService ) ;
566560 electronIpcServer . registerChannel ( 'menubar' , menubarChannel ) ;
@@ -586,6 +580,25 @@ export class CodeApplication extends Disposable {
586580 // Propagate to clients
587581 const windowsMainService = this . windowsMainService = accessor . get ( IWindowsMainService ) ;
588582
583+ // Create a URL handler to open file URIs in the active window
584+ const environmentService = accessor . get ( IEnvironmentService ) ;
585+ urlService . registerHandler ( {
586+ async handleURL ( uri : URI ) : Promise < boolean > {
587+
588+ // Catch file URLs
589+ if ( uri . authority === Schemas . file && ! ! uri . path ) {
590+ const cli = assign ( Object . create ( null ) , environmentService . args ) ;
591+ const urisToOpen = [ { fileUri : uri } ] ;
592+
593+ windowsMainService . open ( { context : OpenContext . API , cli, urisToOpen, gotoLineMode : true } ) ;
594+
595+ return true ;
596+ }
597+
598+ return false ;
599+ }
600+ } ) ;
601+
589602 // Create a URL handler which forwards to the last active window
590603 const activeWindowManager = new ActiveWindowManager ( electronService ) ;
591604 const activeWindowRouter = new StaticRouter ( ctx => activeWindowManager . getActiveClientId ( ) . then ( id => ctx === id ) ) ;
@@ -596,8 +609,6 @@ export class CodeApplication extends Disposable {
596609 // On Mac, Code can be running without any open windows, so we must create a window to handle urls,
597610 // if there is none
598611 if ( isMacintosh ) {
599- const environmentService = accessor . get ( IEnvironmentService ) ;
600-
601612 urlService . registerHandler ( {
602613 async handleURL ( uri : URI ) : Promise < boolean > {
603614 if ( windowsMainService . getWindowCount ( ) === 0 ) {
0 commit comments