提交 340133ac 编写于 作者: R Rachel Macfarlane

Revert "Add strict null checks in issue and launch services, #60565"

This reverts commit cd1a6b4f.
上级 6f139c79
......@@ -429,7 +429,6 @@
"./vs/platform/integrity/common/integrity.ts",
"./vs/platform/integrity/node/integrityServiceImpl.ts",
"./vs/platform/issue/common/issue.ts",
"./vs/platform/issue/electron-main/issueService.ts",
"./vs/platform/issue/node/issueIpc.ts",
"./vs/platform/jsonschemas/common/jsonContributionRegistry.ts",
"./vs/platform/keybinding/common/abstractKeybindingService.ts",
......@@ -441,7 +440,6 @@
"./vs/platform/keybinding/test/common/mockKeybindingService.ts",
"./vs/platform/label/common/label.ts",
"./vs/platform/label/electron-browser/label.contribution.ts",
"./vs/platform/launch/electron-main/launchService.ts",
"./vs/platform/lifecycle/common/lifecycle.ts",
"./vs/platform/lifecycle/electron-browser/lifecycleService.ts",
"./vs/platform/lifecycle/electron-main/lifecycleMain.ts",
......
......@@ -15,15 +15,14 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { isMacintosh, IProcessEnvironment } from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowState } from 'vs/platform/windows/electron-main/windows';
const DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
export class IssueService implements IIssueService {
_serviceBrand: any;
_issueWindow: BrowserWindow | null;
_issueWindow: BrowserWindow;
_issueParentWindow: BrowserWindow;
_processExplorerWindow: BrowserWindow | null;
_processExplorerWindow: BrowserWindow;
constructor(
private machineId: string,
......@@ -109,7 +108,7 @@ export class IssueService implements IIssueService {
this._issueWindow.focus();
return TPromise.as(undefined);
return TPromise.as(null);
}
openProcessExplorer(data: ProcessExplorerData): TPromise<void> {
......@@ -151,7 +150,7 @@ export class IssueService implements IIssueService {
this._processExplorerWindow.loadURL(`${require.toUrl('vs/code/electron-browser/processExplorer/processExplorer.html')}?config=${encodeURIComponent(JSON.stringify(config))}`);
this._processExplorerWindow.on('close', () => this._processExplorerWindow = null);
this._processExplorerWindow.on('close', () => this._processExplorerWindow = void 0);
parentWindow.on('close', () => {
if (this._processExplorerWindow) {
......@@ -164,12 +163,12 @@ export class IssueService implements IIssueService {
// Focus
this._processExplorerWindow.focus();
return TPromise.as(undefined);
return TPromise.as(null);
}
private getWindowPosition(parentWindow: BrowserWindow, defaultWidth: number, defaultHeight: number): IWindowState {
private getWindowPosition(parentWindow: BrowserWindow, defaultWidth: number, defaultHeight: number) {
// We want the new window to open on the same display that the parent is in
let displayToUse: Electron.Display | undefined;
let displayToUse: Electron.Display;
const displays = screen.getAllDisplays();
// Single Display
......@@ -197,14 +196,16 @@ export class IssueService implements IIssueService {
}
}
const state: IWindowState = {
let state = {
width: defaultWidth,
height: defaultHeight
height: defaultHeight,
x: undefined,
y: undefined
};
const displayBounds = displayToUse.bounds;
state.x = displayBounds.x + (displayBounds.width / 2) - (state.width! / 2);
state.y = displayBounds.y + (displayBounds.height / 2) - (state.height! / 2);
state.x = displayBounds.x + (displayBounds.width / 2) - (state.width / 2);
state.y = displayBounds.y + (displayBounds.height / 2) - (state.height / 2);
if (displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) {
if (state.x < displayBounds.x) {
......@@ -223,11 +224,11 @@ export class IssueService implements IIssueService {
state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom
}
if (state.width! > displayBounds.width) {
if (state.width > displayBounds.width) {
state.width = displayBounds.width; // prevent window from exceeding display bounds width
}
if (state.height! > displayBounds.height) {
if (state.height > displayBounds.height) {
state.height = displayBounds.height; // prevent window from exceeding display bounds height
}
}
......@@ -258,11 +259,7 @@ export class IssueService implements IIssueService {
});
}
private getIssueReporterPath(data: IssueReporterData, features: IssueReporterFeatures): string {
if (!this._issueWindow) {
throw new Error('Issue window has been disposed');
}
private getIssueReporterPath(data: IssueReporterData, features: IssueReporterFeatures) {
const windowConfiguration = {
appRoot: this.environmentService.appRoot,
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,
......
......@@ -41,10 +41,6 @@ export interface IMainProcessInfo {
windows: IWindowInfo[];
}
function isUri(uri: URI | null): uri is URI {
return !!uri;
}
function parseOpenUrl(args: ParsedArgs): URI[] {
if (args['open-url'] && args._urls && args._urls.length > 0) {
// --open-url must contain -- followed by the url(s)
......@@ -57,7 +53,7 @@ function parseOpenUrl(args: ParsedArgs): URI[] {
return null;
}
})
.filter(isUri);
.filter(uri => !!uri);
}
return [];
......@@ -103,7 +99,7 @@ export class LaunchChannel implements ILaunchChannel {
return this.service.getLogsPath();
}
throw new Error(`Command '${command}' not found`);
return undefined;
}
}
......@@ -165,7 +161,7 @@ export class LaunchService implements ILaunchService {
}
});
return TPromise.as(undefined);
return TPromise.as(null);
}
// Otherwise handle in windows service
......@@ -174,7 +170,7 @@ export class LaunchService implements ILaunchService {
private startOpenWindow(args: ParsedArgs, userEnv: IProcessEnvironment): TPromise<void> {
const context = !!userEnv['VSCODE_CLI'] ? OpenContext.CLI : OpenContext.DESKTOP;
let usedWindows: ICodeWindow[] | undefined;
let usedWindows: ICodeWindow[];
// Special case extension development
if (!!args.extensionDevelopmentPath) {
......@@ -235,14 +231,14 @@ export class LaunchService implements ILaunchService {
// If the other instance is waiting to be killed, we hook up a window listener if one window
// is being used and only then resolve the startup promise which will kill this second instance.
// In addition, we poll for the wait marker file to be deleted to return.
if (args.wait && args.waitMarkerFilePath && usedWindows && usedWindows.length === 1 && usedWindows[0]) {
if (args.wait && args.waitMarkerFilePath && usedWindows.length === 1 && usedWindows[0]) {
return Promise.race([
this.windowsMainService.waitForWindowCloseOrLoad(usedWindows[0].id),
whenDeleted(args.waitMarkerFilePath)
]).then(() => void 0, () => void 0);
}
return TPromise.as(undefined);
return TPromise.as(null);
}
getMainProcessId(): TPromise<number> {
......@@ -283,12 +279,10 @@ export class LaunchService implements ILaunchService {
if (window.openedFolderUri) {
folderURIs.push(window.openedFolderUri);
} else if (window.openedWorkspace) {
const workspace = this.workspacesMainService.resolveWorkspaceSync(window.openedWorkspace.configPath);
if (workspace) {
workspace.folders.forEach(root => {
folderURIs.push(root.uri);
});
}
const rootFolders = this.workspacesMainService.resolveWorkspaceSync(window.openedWorkspace.configPath).folders;
rootFolders.forEach(root => {
folderURIs.push(root.uri);
});
}
return this.browserWindowToInfo(window.win, folderURIs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册