Skip to content

Commit 0a9ef2a

Browse files
author
Benjamin Pasero
committed
code 💄
1 parent 95161e0 commit 0a9ef2a

4 files changed

Lines changed: 27 additions & 22 deletions

File tree

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
309309
if (!currentWindowsState.lastActiveWindow) {
310310
let activeWindow = this.getLastActiveWindow();
311311
if (!activeWindow || activeWindow.isExtensionDevelopmentHost) {
312-
activeWindow = WindowsManager.WINDOWS.filter(w => !w.isExtensionDevelopmentHost)[0];
312+
activeWindow = WindowsManager.WINDOWS.filter(window => !window.isExtensionDevelopmentHost)[0];
313313
}
314314

315315
if (activeWindow) {
@@ -318,7 +318,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
318318
}
319319

320320
// 2.) Find extension host window
321-
const extensionHostWindow = WindowsManager.WINDOWS.filter(w => w.isExtensionDevelopmentHost && !w.isExtensionTestHost)[0];
321+
const extensionHostWindow = WindowsManager.WINDOWS.filter(window => window.isExtensionDevelopmentHost && !window.isExtensionTestHost)[0];
322322
if (extensionHostWindow) {
323323
currentWindowsState.lastPluginDevelopmentHostWindow = this.toWindowState(extensionHostWindow);
324324
}
@@ -329,7 +329,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
329329
// so if we ever want to persist the UI state of the last closed window (window count === 1), it has
330330
// to come from the stored lastClosedWindowState on Win/Linux at least
331331
if (this.getWindowCount() > 1) {
332-
currentWindowsState.openedWindows = WindowsManager.WINDOWS.filter(w => !w.isExtensionDevelopmentHost).map(w => this.toWindowState(w));
332+
currentWindowsState.openedWindows = WindowsManager.WINDOWS.filter(window => !window.isExtensionDevelopmentHost).map(window => this.toWindowState(window));
333333
}
334334

335335
// Persist
@@ -456,7 +456,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
456456

457457
// 1.) focus last active window if we are not instructed to open any paths
458458
if (focusLastActive) {
459-
const lastActiveWindow = usedWindows.filter(w => w.backupPath === this.windowsState.lastActiveWindow!.backupPath);
459+
const lastActiveWindow = usedWindows.filter(window => window.backupPath === this.windowsState.lastActiveWindow!.backupPath);
460460
if (lastActiveWindow.length) {
461461
lastActiveWindow[0].focus();
462462
focusLastOpened = false;
@@ -490,7 +490,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
490490

491491
// Remember in recent document list (unless this opens for extension development)
492492
// Also do not add paths when files are opened for diffing, only if opened individually
493-
if (!usedWindows.some(w => w.isExtensionDevelopmentHost) && !openConfig.diffMode && !openConfig.noRecentEntry) {
493+
if (!usedWindows.some(window => window.isExtensionDevelopmentHost) && !openConfig.diffMode && !openConfig.noRecentEntry) {
494494
const recents: IRecent[] = [];
495495
for (let pathToOpen of pathsToOpen) {
496496
if (pathToOpen.workspace) {
@@ -556,7 +556,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
556556
const fileToCheck = fileInputs.filesToOpenOrCreate[0] || fileInputs.filesToDiff[0];
557557

558558
// only look at the windows with correct authority
559-
const windows = WindowsManager.WINDOWS.filter(w => w.remoteAuthority === fileInputs!.remoteAuthority);
559+
const windows = WindowsManager.WINDOWS.filter(window => window.remoteAuthority === fileInputs!.remoteAuthority);
560560

561561
const bestWindowOrFolder = findBestWindowOrFolderForFile({
562562
windows,
@@ -1599,7 +1599,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
15991599
}
16001600

16011601
getLastActiveWindowForAuthority(remoteAuthority: string | undefined): ICodeWindow | undefined {
1602-
return getLastActiveWindow(WindowsManager.WINDOWS.filter(w => w.remoteAuthority === remoteAuthority));
1602+
return getLastActiveWindow(WindowsManager.WINDOWS.filter(window => window.remoteAuthority === remoteAuthority));
16031603
}
16041604

16051605
openNewWindow(context: OpenContext, options?: INewWindowOptions): ICodeWindow[] {
@@ -1642,13 +1642,13 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
16421642
}
16431643

16441644
sendToAll(channel: string, payload?: any, windowIdsToIgnore?: number[]): void {
1645-
WindowsManager.WINDOWS.forEach(w => {
1646-
if (windowIdsToIgnore && windowIdsToIgnore.indexOf(w.id) >= 0) {
1647-
return; // do not send if we are instructed to ignore it
1645+
for (const window of WindowsManager.WINDOWS) {
1646+
if (windowIdsToIgnore && windowIdsToIgnore.indexOf(window.id) >= 0) {
1647+
continue; // do not send if we are instructed to ignore it
16481648
}
16491649

1650-
w.sendWhenReady(channel, payload);
1651-
});
1650+
window.sendWhenReady(channel, payload);
1651+
}
16521652
}
16531653

16541654
getFocusedWindow(): ICodeWindow | undefined {
@@ -1661,7 +1661,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
16611661
}
16621662

16631663
getWindowById(windowId: number): ICodeWindow | undefined {
1664-
const res = WindowsManager.WINDOWS.filter(w => w.id === windowId);
1664+
const res = WindowsManager.WINDOWS.filter(window => window.id === windowId);
16651665
if (res && res.length === 1) {
16661666
return res[0];
16671667
}

src/vs/platform/backup/electron-main/backupMainService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class BackupMainService implements IBackupMainService {
138138
}
139139

140140
registerWorkspaceBackupSync(workspaceInfo: IWorkspaceBackupInfo, migrateFrom?: string): string {
141-
if (!this.rootWorkspaces.some(w => workspaceInfo.workspace.id === w.workspace.id)) {
141+
if (!this.rootWorkspaces.some(window => workspaceInfo.workspace.id === window.workspace.id)) {
142142
this.rootWorkspaces.push(workspaceInfo);
143143
this.saveSync();
144144
}
@@ -219,7 +219,7 @@ export class BackupMainService implements IBackupMainService {
219219
backupFolder = this.getRandomEmptyWindowId();
220220
}
221221

222-
if (!this.emptyWorkspaces.some(w => !!w.backupFolder && isEqual(w.backupFolder, backupFolder!, !platform.isLinux))) {
222+
if (!this.emptyWorkspaces.some(window => !!window.backupFolder && isEqual(window.backupFolder, backupFolder!, !platform.isLinux))) {
223223
this.emptyWorkspaces.push({ backupFolder, remoteAuthority });
224224
this.saveSync();
225225
}
@@ -353,7 +353,7 @@ export class BackupMainService implements IBackupMainService {
353353

354354
// New empty window backup
355355
let newBackupFolder = this.getRandomEmptyWindowId();
356-
while (this.emptyWorkspaces.some(w => !!w.backupFolder && isEqual(w.backupFolder, newBackupFolder, platform.isLinux))) {
356+
while (this.emptyWorkspaces.some(window => !!window.backupFolder && isEqual(window.backupFolder, newBackupFolder, platform.isLinux))) {
357357
newBackupFolder = this.getRandomEmptyWindowId();
358358
}
359359

@@ -374,7 +374,7 @@ export class BackupMainService implements IBackupMainService {
374374

375375
// New empty window backup
376376
let newBackupFolder = this.getRandomEmptyWindowId();
377-
while (this.emptyWorkspaces.some(w => !!w.backupFolder && isEqual(w.backupFolder, newBackupFolder, platform.isLinux))) {
377+
while (this.emptyWorkspaces.some(window => !!window.backupFolder && isEqual(window.backupFolder, newBackupFolder, platform.isLinux))) {
378378
newBackupFolder = this.getRandomEmptyWindowId();
379379
}
380380

@@ -457,4 +457,4 @@ export class BackupMainService implements IBackupMainService {
457457
protected getLegacyFolderHash(folderPath: string): string {
458458
return crypto.createHash('md5').update(platform.isLinux ? folderPath : folderPath.toLowerCase()).digest('hex');
459459
}
460-
}
460+
}

src/vs/platform/backup/test/electron-main/backupMainService.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ suite('BackupMainService', () => {
322322
assert.deepEqual(json.folderURIWorkspaces, [URI.file(folderPath).toString()]);
323323
assert.deepEqual(json.rootURIWorkspaces, [{ id: workspace.id, configURIPath: URI.file(workspacePath).toString() }]);
324324

325-
assertEqualUris(service.getWorkspaceBackups().map(w => w.workspace.configPath), [workspace.configPath]);
325+
assertEqualUris(service.getWorkspaceBackups().map(window => window.workspace.configPath), [workspace.configPath]);
326326
});
327327
});
328328

@@ -731,4 +731,4 @@ suite('BackupMainService', () => {
731731
}
732732
});
733733
});
734-
});
734+
});

src/vs/platform/windows/electron-main/windowsService.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,14 @@ export class WindowsService extends Disposable implements IWindowsService, IURLH
322322
this.logService.trace('windowsService#getWindows');
323323

324324
const windows = this.windowsMainService.getWindows();
325-
const result = windows.map(w => ({ id: w.id, workspace: w.openedWorkspace, folderUri: w.openedFolderUri, title: w.win.getTitle(), filename: w.getRepresentedFilename() }));
326325

327-
return result;
326+
return windows.map(window => ({
327+
id: window.id,
328+
workspace: window.openedWorkspace,
329+
folderUri: window.openedFolderUri,
330+
title: window.win.getTitle(),
331+
filename: window.getRepresentedFilename()
332+
}));
328333
}
329334

330335
async getWindowCount(): Promise<number> {

0 commit comments

Comments
 (0)