提交 14c4fde6 编写于 作者: M Matt Bierner

Strict null check extHostQuickOpen

上级 8f3cda12
......@@ -95,6 +95,7 @@
"./vs/workbench/api/node/extHostMessageService.ts",
"./vs/workbench/api/node/extHostOutputService.ts",
"./vs/workbench/api/node/extHostProgress.ts",
"./vs/workbench/api/node/extHostQuickOpen.ts",
"./vs/workbench/api/node/extHostSearch.fileIndex.ts",
"./vs/workbench/api/node/extHostSearch.ts",
"./vs/workbench/api/node/extHostStorage.ts",
......
......@@ -85,7 +85,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
// ---- input
$input(options: InputBoxOptions, validateInput: boolean, token: CancellationToken): Promise<string> {
$input(options: InputBoxOptions | undefined, validateInput: boolean, token: CancellationToken): Promise<string> {
const inputOptions: IInputOptions = Object.create(null);
if (options) {
......
......@@ -460,7 +460,7 @@ export interface MainThreadQuickOpenShape extends IDisposable {
$show(instance: number, options: IPickOptions<TransferQuickPickItems>, token: CancellationToken): Promise<number | number[] | undefined>;
$setItems(instance: number, items: TransferQuickPickItems[]): Promise<void>;
$setError(instance: number, error: Error): Promise<void>;
$input(options: vscode.InputBoxOptions, validateInput: boolean, token: CancellationToken): Promise<string>;
$input(options: vscode.InputBoxOptions | undefined, validateInput: boolean, token: CancellationToken): Promise<string>;
$createOrUpdate(params: TransferQuickInput): Promise<void>;
$dispose(id: number): Promise<void>;
}
......
......@@ -116,6 +116,9 @@ class ExtensionStoragePath {
return Promise.resolve(undefined);
}
if (!this._environment.appSettingsHome) {
return undefined;
}
const storageName = this._workspace.id;
const storagePath = path.join(this._environment.appSettingsHome.fsPath, 'workspaceStorage', storageName);
......
......@@ -15,6 +15,7 @@ import { URI } from 'vs/base/common/uri';
import { ThemeIcon, QuickInputButtons } from 'vs/workbench/api/node/extHostTypes';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { coalesce } from 'vs/base/common/arrays';
export type Item = string | QuickPickItem;
......@@ -24,7 +25,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
private _workspace: IExtHostWorkspaceProvider;
private _commands: ExtHostCommands;
private _onDidSelectItem: (handle: number) => void;
private _onDidSelectItem?: (handle: number) => void;
private _validateInput?: (input: string) => string | undefined | null | Thenable<string | undefined | null>;
private _sessions = new Map<number, ExtHostQuickInput>();
......@@ -158,12 +159,15 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
// ---- workspace folder picker
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder> {
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder | undefined> {
return this._commands.executeCommand('_workbench.pickWorkspaceFolder', [options]).then(async (selectedFolder: WorkspaceFolder) => {
if (!selectedFolder) {
return undefined;
}
const workspaceFolders = await this._workspace.getWorkspaceFolders2();
if (!workspaceFolders) {
return undefined;
}
return workspaceFolders.filter(folder => folder.uri.toString() === selectedFolder.uri.toString())[0];
});
}
......@@ -382,7 +386,9 @@ class ExtHostQuickInput implements QuickInput {
_fireDidTriggerButton(handle: number) {
const button = this._handlesToButtons.get(handle);
this._onDidTriggerButtonEmitter.fire(button);
if (button) {
this._onDidTriggerButtonEmitter.fire(button);
}
}
_fireDidHide() {
......@@ -437,9 +443,13 @@ class ExtHostQuickInput implements QuickInput {
}
}
function getIconUris(iconPath: QuickInputButton['iconPath']) {
function getIconUris(iconPath: QuickInputButton['iconPath']): { dark: URI, light?: URI } | undefined {
const dark = getDarkIconUri(iconPath);
const light = getLightIconUri(iconPath);
return { dark: getDarkIconUri(iconPath) || light, light };
if (!light && !dark) {
return undefined;
}
return { dark: (dark || light)!, light };
}
function getLightIconUri(iconPath: QuickInputButton['iconPath']) {
......@@ -563,13 +573,13 @@ class ExtHostQuickPick<T extends QuickPickItem> extends ExtHostQuickInput implem
onDidChangeSelection = this._onDidChangeSelectionEmitter.event;
_fireDidChangeActive(handles: number[]) {
const items = handles.map(handle => this._handlesToItems.get(handle));
const items = coalesce(handles.map(handle => this._handlesToItems.get(handle)));
this._activeItems = items;
this._onDidChangeActiveEmitter.fire(items);
}
_fireDidChangeSelection(handles: number[]) {
const items = handles.map(handle => this._handlesToItems.get(handle));
const items = coalesce(handles.map(handle => this._handlesToItems.get(handle)));
this._selectedItems = items;
this._onDidChangeSelectionEmitter.fire(items);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册