mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Strict null check extHostQuickOpen
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user