diff --git a/src/vs/code/electron-main/diagnostics.ts b/src/vs/code/electron-main/diagnostics.ts index 3db04d06bdc..3bb9e182899 100644 --- a/src/vs/code/electron-main/diagnostics.ts +++ b/src/vs/code/electron-main/diagnostics.ts @@ -16,6 +16,7 @@ import { repeat, pad } from 'vs/base/common/strings'; import { isWindows } from 'vs/base/common/platform'; import { app } from 'electron'; import { basename } from 'path'; +import URI from 'vs/base/common/uri'; export interface VersionInfo { vscodeVersion: string; @@ -50,29 +51,35 @@ export function getPerformanceInfo(info: IMainProcessInfo): Promise window.folders && window.folders.length > 0)) { + if (info.windows.some(window => window.folderURIs && window.folderURIs.length > 0)) { info.windows.forEach(window => { - if (window.folders.length === 0) { + if (window.folderURIs.length === 0) { return; } workspaceInfoMessages.push(`| Window (${window.title})`); - window.folders.forEach(folder => { - workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(async stats => { + window.folderURIs.forEach(uriComponents => { + const folderUri = URI.revive(uriComponents); + if (folderUri.scheme === 'file') { + const folder = folderUri.fsPath; + workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(async stats => { - let countMessage = `${stats.fileCount} files`; - if (stats.maxFilesReached) { - countMessage = `more than ${countMessage}`; - } - workspaceInfoMessages.push(`| Folder (${basename(folder)}): ${countMessage}`); - workspaceInfoMessages.push(formatWorkspaceStats(stats)); + let countMessage = `${stats.fileCount} files`; + if (stats.maxFilesReached) { + countMessage = `more than ${countMessage}`; + } + workspaceInfoMessages.push(`| Folder (${basename(folder)}): ${countMessage}`); + workspaceInfoMessages.push(formatWorkspaceStats(stats)); - const launchConfigs = await collectLaunchConfigs(folder); - if (launchConfigs.length > 0) { - workspaceInfoMessages.push(formatLaunchConfigs(launchConfigs)); - } - })); + const launchConfigs = await collectLaunchConfigs(folder); + if (launchConfigs.length > 0) { + workspaceInfoMessages.push(formatLaunchConfigs(launchConfigs)); + } + })); + } else { + workspaceInfoMessages.push(`| Folder (${folderUri.toString()}): RPerformance stats not available.`); + } }); }); } @@ -129,33 +136,39 @@ export function printDiagnostics(info: IMainProcessInfo): Promise { // Workspace Stats const workspaceStatPromises = []; - if (info.windows.some(window => window.folders && window.folders.length > 0)) { + if (info.windows.some(window => window.folderURIs && window.folderURIs.length > 0)) { console.log(''); console.log('Workspace Stats: '); info.windows.forEach(window => { - if (window.folders.length === 0) { + if (window.folderURIs.length === 0) { return; } console.log(`| Window (${window.title})`); - window.folders.forEach(folder => { - workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(async stats => { - let countMessage = `${stats.fileCount} files`; - if (stats.maxFilesReached) { - countMessage = `more than ${countMessage}`; - } - console.log(`| Folder (${basename(folder)}): ${countMessage}`); - console.log(formatWorkspaceStats(stats)); - - await collectLaunchConfigs(folder).then(launchConfigs => { - if (launchConfigs.length > 0) { - console.log(formatLaunchConfigs(launchConfigs)); + window.folderURIs.forEach(uriComponents => { + const folderUri = URI.revive(uriComponents); + if (folderUri.scheme === 'file') { + const folder = folderUri.fsPath; + workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(async stats => { + let countMessage = `${stats.fileCount} files`; + if (stats.maxFilesReached) { + countMessage = `more than ${countMessage}`; } - }); - }).catch(error => { - console.log(`| Error: Unable to collect workpsace stats for folder ${folder} (${error.toString()})`); - })); + console.log(`| Folder (${basename(folder)}): ${countMessage}`); + console.log(formatWorkspaceStats(stats)); + + await collectLaunchConfigs(folder).then(launchConfigs => { + if (launchConfigs.length > 0) { + console.log(formatLaunchConfigs(launchConfigs)); + } + }); + }).catch(error => { + console.log(`| Error: Unable to collect workspace stats for folder ${folder} (${error.toString()})`); + })); + } else { + console.log(`| Folder (${folderUri.toString()}): Workspace stats not available.`); + } }); }); } diff --git a/src/vs/code/electron-main/launch.ts b/src/vs/code/electron-main/launch.ts index 5dc5861bb5a..3efe2e81449 100644 --- a/src/vs/code/electron-main/launch.ts +++ b/src/vs/code/electron-main/launch.ts @@ -16,9 +16,8 @@ import { OpenContext, IWindowSettings } from 'vs/platform/windows/common/windows import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows'; import { whenDeleted } from 'vs/base/node/pfs'; import { IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces'; -import { Schemas } from 'vs/base/common/network'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import URI from 'vs/base/common/uri'; +import URI, { UriComponents } from 'vs/base/common/uri'; import { BrowserWindow } from 'electron'; import { Event } from 'vs/base/common/event'; @@ -33,7 +32,7 @@ export interface IStartArguments { export interface IWindowInfo { pid: number; title: string; - folders: string[]; + folderURIs: UriComponents[]; } export interface IMainProcessInfo { @@ -275,29 +274,25 @@ export class LaunchService implements ILaunchService { } private codeWindowToInfo(window: ICodeWindow): IWindowInfo { - const folders: string[] = []; + const folderURIs: URI[] = []; if (window.openedFolderUri) { - if (window.openedFolderUri.scheme === Schemas.file) { - folders.push(window.openedFolderUri.fsPath); // todo@remote signal remote folders? - } + folderURIs.push(window.openedFolderUri); } else if (window.openedWorkspace) { const rootFolders = this.workspacesMainService.resolveWorkspaceSync(window.openedWorkspace.configPath).folders; rootFolders.forEach(root => { - if (root.uri.scheme === Schemas.file) { // todo@remote signal remote folders? - folders.push(root.uri.fsPath); - } + folderURIs.push(root.uri); }); } - return this.browserWindowToInfo(window.win, folders); + return this.browserWindowToInfo(window.win, folderURIs); } - private browserWindowToInfo(win: BrowserWindow, folders: string[] = []): IWindowInfo { + private browserWindowToInfo(win: BrowserWindow, folderURIs: URI[] = []): IWindowInfo { return { pid: win.webContents.getOSProcessId(), title: win.getTitle(), - folders + folderURIs } as IWindowInfo; } }