未验证 提交 f40bd2f6 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #69814 from Microsoft/tyriar/snc_terminal

Strict null check contrib/terminal
......@@ -251,7 +251,7 @@ export interface ITerminalService {
findPrevious(): void;
setContainers(panelContainer: HTMLElement, terminalContainer: HTMLElement): void;
selectDefaultWindowsShell(): Promise<string>;
selectDefaultWindowsShell(): Promise<string | undefined>;
setWorkspaceShellAllowed(isAllowed: boolean): void;
requestExtHostProcess(proxy: ITerminalProcessExtHostProxy, shellLaunchConfig: IShellLaunchConfig, activeWorkspaceRootUri: URI, cols: number, rows: number): void;
......
......@@ -92,7 +92,7 @@ export abstract class TerminalService implements ITerminalService {
public abstract createTerminalRenderer(name: string): ITerminalInstance;
public abstract createInstance(terminalFocusContextKey: IContextKey<boolean>, configHelper: ITerminalConfigHelper, container: HTMLElement, shellLaunchConfig: IShellLaunchConfig, doCreateProcess: boolean): ITerminalInstance;
public abstract getActiveOrCreateInstance(wasNewTerminalAction?: boolean): ITerminalInstance;
public abstract selectDefaultWindowsShell(): Promise<string>;
public abstract selectDefaultWindowsShell(): Promise<string | undefined>;
public abstract setContainers(panelContainer: HTMLElement, terminalContainer: HTMLElement): void;
public abstract requestExtHostProcess(proxy: ITerminalProcessExtHostProxy, shellLaunchConfig: IShellLaunchConfig, activeWorkspaceRootUri: URI, cols: number, rows: number): void;
......
......@@ -64,7 +64,10 @@ export class TerminalService extends AbstractTerminalService implements ITermina
if (request.termProgram === 'vscode' && request.filesToWait) {
pfs.whenDeleted(request.filesToWait.waitMarkerFilePath).then(() => {
if (this.terminalInstances.length > 0) {
this.getActiveInstance().focus();
const terminal = this.getActiveInstance();
if (terminal) {
terminal.focus();
}
}
});
}
......@@ -215,14 +218,14 @@ export class TerminalService extends AbstractTerminalService implements ITermina
);
}
public selectDefaultWindowsShell(): Promise<string> {
public selectDefaultWindowsShell(): Promise<string | undefined> {
return this._detectWindowsShells().then(shells => {
const options: IPickOptions<IQuickPickItem> = {
placeHolder: nls.localize('terminal.integrated.chooseWindowsShell', "Select your preferred terminal shell, you can change this later in your settings")
};
return this._quickInputService.pick(shells, options).then(value => {
if (!value) {
return null;
return undefined;
}
const shell = value.description;
return this._configurationService.updateValue('terminal.integrated.shell.windows', shell, ConfigurationTarget.USER).then(() => shell);
......@@ -270,13 +273,13 @@ export class TerminalService extends AbstractTerminalService implements ITermina
});
}
private _validateShellPaths(label: string, potentialPaths: string[]): Promise<[string, string]> {
private _validateShellPaths(label: string, potentialPaths: string[]): Promise<[string, string] | null> {
if (potentialPaths.length === 0) {
return Promise.resolve(null);
}
const current = potentialPaths.shift();
return pfs.fileExists(current).then(exists => {
return pfs.fileExists(current!).then(exists => {
if (!exists) {
if (potentialPaths.length === 0) {
return null;
}
return this._validateShellPaths(label, potentialPaths);
}
return [label, current] as [string, string];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册