@@ -31,7 +31,7 @@ import { Schemas } from 'vs/base/common/network';
3131import { URI } from 'vs/base/common/uri' ;
3232import { getComparisonKey , isEqual , normalizePath , originalFSPath , hasTrailingPathSeparator , removeTrailingPathSeparator } from 'vs/base/common/resources' ;
3333import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts' ;
34- import { restoreWindowsState , WindowsStateStorageData , getWindowsStateStoreData } from 'vs/code /electron-main/windowsStateStorage' ;
34+ import { restoreWindowsState , WindowsStateStorageData , getWindowsStateStoreData } from 'vs/platform/windows /electron-main/windowsStateStorage' ;
3535import { getWorkspaceIdentifier , IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService' ;
3636import { once } from 'vs/base/common/functional' ;
3737import { Disposable } from 'vs/base/common/lifecycle' ;
@@ -149,7 +149,7 @@ interface IWorkspacePathToOpen {
149149 label ?: string ;
150150}
151151
152- export class WindowsManager extends Disposable implements IWindowsMainService {
152+ export class WindowsMainService extends Disposable implements IWindowsMainService {
153153
154154 _serviceBrand : undefined ;
155155
@@ -185,7 +185,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
185185 ) {
186186 super ( ) ;
187187
188- this . windowsState = restoreWindowsState ( this . stateService . getItem < WindowsStateStorageData > ( WindowsManager . windowsStateStorageKey ) ) ;
188+ this . windowsState = restoreWindowsState ( this . stateService . getItem < WindowsStateStorageData > ( WindowsMainService . windowsStateStorageKey ) ) ;
189189 if ( ! Array . isArray ( this . windowsState . openedWindows ) ) {
190190 this . windowsState . openedWindows = [ ] ;
191191 }
@@ -299,7 +299,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
299299 if ( ! currentWindowsState . lastActiveWindow ) {
300300 let activeWindow = this . getLastActiveWindow ( ) ;
301301 if ( ! activeWindow || activeWindow . isExtensionDevelopmentHost ) {
302- activeWindow = WindowsManager . WINDOWS . filter ( window => ! window . isExtensionDevelopmentHost ) [ 0 ] ;
302+ activeWindow = WindowsMainService . WINDOWS . filter ( window => ! window . isExtensionDevelopmentHost ) [ 0 ] ;
303303 }
304304
305305 if ( activeWindow ) {
@@ -308,7 +308,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
308308 }
309309
310310 // 2.) Find extension host window
311- const extensionHostWindow = WindowsManager . WINDOWS . filter ( window => window . isExtensionDevelopmentHost && ! window . isExtensionTestHost ) [ 0 ] ;
311+ const extensionHostWindow = WindowsMainService . WINDOWS . filter ( window => window . isExtensionDevelopmentHost && ! window . isExtensionTestHost ) [ 0 ] ;
312312 if ( extensionHostWindow ) {
313313 currentWindowsState . lastPluginDevelopmentHostWindow = this . toWindowState ( extensionHostWindow ) ;
314314 }
@@ -319,11 +319,11 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
319319 // so if we ever want to persist the UI state of the last closed window (window count === 1), it has
320320 // to come from the stored lastClosedWindowState on Win/Linux at least
321321 if ( this . getWindowCount ( ) > 1 ) {
322- currentWindowsState . openedWindows = WindowsManager . WINDOWS . filter ( window => ! window . isExtensionDevelopmentHost ) . map ( window => this . toWindowState ( window ) ) ;
322+ currentWindowsState . openedWindows = WindowsMainService . WINDOWS . filter ( window => ! window . isExtensionDevelopmentHost ) . map ( window => this . toWindowState ( window ) ) ;
323323 }
324324
325325 // Persist
326- this . stateService . setItem ( WindowsManager . windowsStateStorageKey , getWindowsStateStoreData ( currentWindowsState ) ) ;
326+ this . stateService . setItem ( WindowsMainService . windowsStateStorageKey , getWindowsStateStoreData ( currentWindowsState ) ) ;
327327 }
328328
329329 // See note on #onBeforeShutdown() for details how these events are flowing
@@ -546,7 +546,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
546546 const fileToCheck = fileInputs . filesToOpenOrCreate [ 0 ] || fileInputs . filesToDiff [ 0 ] ;
547547
548548 // only look at the windows with correct authority
549- const windows = WindowsManager . WINDOWS . filter ( window => window . remoteAuthority === fileInputs ! . remoteAuthority ) ;
549+ const windows = WindowsMainService . WINDOWS . filter ( window => window . remoteAuthority === fileInputs ! . remoteAuthority ) ;
550550
551551 const bestWindowOrFolder = findBestWindowOrFolderForFile ( {
552552 windows,
@@ -602,7 +602,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
602602 if ( allWorkspacesToOpen . length > 0 ) {
603603
604604 // Check for existing instances
605- const windowsOnWorkspace = arrays . coalesce ( allWorkspacesToOpen . map ( workspaceToOpen => findWindowOnWorkspace ( WindowsManager . WINDOWS , workspaceToOpen . workspace ) ) ) ;
605+ const windowsOnWorkspace = arrays . coalesce ( allWorkspacesToOpen . map ( workspaceToOpen => findWindowOnWorkspace ( WindowsMainService . WINDOWS , workspaceToOpen . workspace ) ) ) ;
606606 if ( windowsOnWorkspace . length > 0 ) {
607607 const windowOnWorkspace = windowsOnWorkspace [ 0 ] ;
608608 const fileInputsForWindow = ( fileInputs && fileInputs . remoteAuthority === windowOnWorkspace . remoteAuthority ) ? fileInputs : undefined ;
@@ -644,7 +644,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
644644 if ( allFoldersToOpen . length > 0 ) {
645645
646646 // Check for existing instances
647- const windowsOnFolderPath = arrays . coalesce ( allFoldersToOpen . map ( folderToOpen => findWindowOnWorkspace ( WindowsManager . WINDOWS , folderToOpen . folderUri ) ) ) ;
647+ const windowsOnFolderPath = arrays . coalesce ( allFoldersToOpen . map ( folderToOpen => findWindowOnWorkspace ( WindowsMainService . WINDOWS , folderToOpen . folderUri ) ) ) ;
648648 if ( windowsOnFolderPath . length > 0 ) {
649649 const windowOnFolderPath = windowsOnFolderPath [ 0 ] ;
650650 const fileInputsForWindow = fileInputs && fileInputs . remoteAuthority === windowOnFolderPath . remoteAuthority ? fileInputs : undefined ;
@@ -1216,7 +1216,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
12161216 // Reload an existing extension development host window on the same path
12171217 // We currently do not allow more than one extension development window
12181218 // on the same extension path.
1219- const existingWindow = findWindowOnExtensionDevelopmentPath ( WindowsManager . WINDOWS , extensionDevelopmentPath ) ;
1219+ const existingWindow = findWindowOnExtensionDevelopmentPath ( WindowsMainService . WINDOWS , extensionDevelopmentPath ) ;
12201220 if ( existingWindow ) {
12211221 this . reload ( existingWindow , openConfig . cli ) ;
12221222 existingWindow . focus ( ) ; // make sure it gets focus and is restored
@@ -1270,23 +1270,23 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
12701270
12711271 cliArgs = cliArgs . filter ( path => {
12721272 const uri = URI . file ( path ) ;
1273- if ( ! ! findWindowOnWorkspaceOrFolderUri ( WindowsManager . WINDOWS , uri ) ) {
1273+ if ( ! ! findWindowOnWorkspaceOrFolderUri ( WindowsMainService . WINDOWS , uri ) ) {
12741274 return false ;
12751275 }
12761276 return uri . authority === authority ;
12771277 } ) ;
12781278
12791279 folderUris = folderUris . filter ( uri => {
12801280 const u = this . argToUri ( uri ) ;
1281- if ( ! ! findWindowOnWorkspaceOrFolderUri ( WindowsManager . WINDOWS , u ) ) {
1281+ if ( ! ! findWindowOnWorkspaceOrFolderUri ( WindowsMainService . WINDOWS , u ) ) {
12821282 return false ;
12831283 }
12841284 return u ? u . authority === authority : false ;
12851285 } ) ;
12861286
12871287 fileUris = fileUris . filter ( uri => {
12881288 const u = this . argToUri ( uri ) ;
1289- if ( ! ! findWindowOnWorkspaceOrFolderUri ( WindowsManager . WINDOWS , u ) ) {
1289+ if ( ! ! findWindowOnWorkspaceOrFolderUri ( WindowsMainService . WINDOWS , u ) ) {
12901290 return false ;
12911291 }
12921292 return u ? u . authority === authority : false ;
@@ -1390,10 +1390,10 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
13901390 }
13911391
13921392 // Add to our list of windows
1393- WindowsManager . WINDOWS . push ( window ) ;
1393+ WindowsMainService . WINDOWS . push ( window ) ;
13941394
13951395 // Indicate number change via event
1396- this . _onWindowsCountChanged . fire ( { oldCount : WindowsManager . WINDOWS . length - 1 , newCount : WindowsManager . WINDOWS . length } ) ;
1396+ this . _onWindowsCountChanged . fire ( { oldCount : WindowsMainService . WINDOWS . length - 1 , newCount : WindowsMainService . WINDOWS . length } ) ;
13971397
13981398 // Window Events
13991399 once ( window . onClose ) ( ( ) => this . onWindowClosed ( window ! ) ) ;
@@ -1570,14 +1570,14 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
15701570 }
15711571
15721572 private ensureNoOverlap ( state : ISingleWindowState ) : ISingleWindowState {
1573- if ( WindowsManager . WINDOWS . length === 0 ) {
1573+ if ( WindowsMainService . WINDOWS . length === 0 ) {
15741574 return state ;
15751575 }
15761576
15771577 state . x = typeof state . x === 'number' ? state . x : 0 ;
15781578 state . y = typeof state . y === 'number' ? state . y : 0 ;
15791579
1580- const existingWindowBounds = WindowsManager . WINDOWS . map ( win => win . getBounds ( ) ) ;
1580+ const existingWindowBounds = WindowsMainService . WINDOWS . map ( win => win . getBounds ( ) ) ;
15811581 while ( existingWindowBounds . some ( b => b . x === state . x || b . y === state . y ) ) {
15821582 state . x += 30 ;
15831583 state . y += 30 ;
@@ -1616,11 +1616,11 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
16161616 }
16171617
16181618 getLastActiveWindow ( ) : ICodeWindow | undefined {
1619- return getLastActiveWindow ( WindowsManager . WINDOWS ) ;
1619+ return getLastActiveWindow ( WindowsMainService . WINDOWS ) ;
16201620 }
16211621
16221622 private getLastActiveWindowForAuthority ( remoteAuthority : string | undefined ) : ICodeWindow | undefined {
1623- return getLastActiveWindow ( WindowsManager . WINDOWS . filter ( window => window . remoteAuthority === remoteAuthority ) ) ;
1623+ return getLastActiveWindow ( WindowsMainService . WINDOWS . filter ( window => window . remoteAuthority === remoteAuthority ) ) ;
16241624 }
16251625
16261626 openEmptyWindow ( context : OpenContext , options ?: IOpenEmptyWindowOptions ) : ICodeWindow [ ] {
@@ -1645,7 +1645,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
16451645 }
16461646
16471647 sendToAll ( channel : string , payload ?: any , windowIdsToIgnore ?: number [ ] ) : void {
1648- for ( const window of WindowsManager . WINDOWS ) {
1648+ for ( const window of WindowsMainService . WINDOWS ) {
16491649 if ( windowIdsToIgnore && windowIdsToIgnore . indexOf ( window . id ) >= 0 ) {
16501650 continue ; // do not send if we are instructed to ignore it
16511651 }
@@ -1664,26 +1664,26 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
16641664 }
16651665
16661666 getWindowById ( windowId : number ) : ICodeWindow | undefined {
1667- const res = WindowsManager . WINDOWS . filter ( window => window . id === windowId ) ;
1667+ const res = WindowsMainService . WINDOWS . filter ( window => window . id === windowId ) ;
16681668 return arrays . firstOrDefault ( res ) ;
16691669 }
16701670
16711671 getWindows ( ) : ICodeWindow [ ] {
1672- return WindowsManager . WINDOWS ;
1672+ return WindowsMainService . WINDOWS ;
16731673 }
16741674
16751675 getWindowCount ( ) : number {
1676- return WindowsManager . WINDOWS . length ;
1676+ return WindowsMainService . WINDOWS . length ;
16771677 }
16781678
16791679 private onWindowClosed ( win : ICodeWindow ) : void {
16801680
16811681 // Remove from our list so that Electron can clean it up
1682- const index = WindowsManager . WINDOWS . indexOf ( win ) ;
1683- WindowsManager . WINDOWS . splice ( index , 1 ) ;
1682+ const index = WindowsMainService . WINDOWS . indexOf ( win ) ;
1683+ WindowsMainService . WINDOWS . splice ( index , 1 ) ;
16841684
16851685 // Emit
1686- this . _onWindowsCountChanged . fire ( { oldCount : WindowsManager . WINDOWS . length + 1 , newCount : WindowsManager . WINDOWS . length } ) ;
1686+ this . _onWindowsCountChanged . fire ( { oldCount : WindowsMainService . WINDOWS . length + 1 , newCount : WindowsMainService . WINDOWS . length } ) ;
16871687 this . _onWindowClose . fire ( win . id ) ;
16881688 }
16891689
0 commit comments