Skip to content

Commit

Permalink
Use class with static fields (fixes microsoft#55494)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Aug 3, 2018
1 parent dea3960 commit 1b675ac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
9 changes: 7 additions & 2 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6892,15 +6892,20 @@ declare module 'vscode' {
/**
* Predefined buttons for [QuickPick](#QuickPick) and [InputBox](#InputBox).
*/
export namespace QuickInputButtons {
export class QuickInputButtons {

/**
* A back button for [QuickPick](#QuickPick) and [InputBox](#InputBox).
*
* When a navigation 'back' button is needed this one should be used for consistency.
* It comes with a predefined icon, tooltip and location.
*/
export const Back: QuickInputButton;
static readonly Back: QuickInputButton;

/**
* @hidden
*/
private constructor();
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,6 @@ export function createApiFactory(
},
};

// namespace: QuickInputButtons
const QuickInputButtons: typeof vscode.QuickInputButtons = {
Back: extHostQuickOpen.backButton,
};

// namespace: workspace
const workspace: typeof vscode.workspace = {
get rootPath() {
Expand Down Expand Up @@ -732,7 +727,7 @@ export function createApiFactory(
OverviewRulerLane: OverviewRulerLane,
ParameterInformation: extHostTypes.ParameterInformation,
Position: extHostTypes.Position,
QuickInputButtons,
QuickInputButtons: extHostTypes.QuickInputButtons,
Range: extHostTypes.Range,
Selection: extHostTypes.Selection,
SignatureHelp: extHostTypes.SignatureHelp,
Expand Down
10 changes: 3 additions & 7 deletions src/vs/workbench/api/node/extHostQuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { InputBox, InputBoxOptions, QuickInput, QuickInputButton, QuickPick, QuickPickItem, QuickPickOptions, WorkspaceFolder, WorkspaceFolderPickOptions } from 'vscode';
import { ExtHostQuickOpenShape, IMainContext, MainContext, MainThreadQuickOpenShape, TransferQuickPickItems, TransferQuickInput, TransferQuickInputButton } from './extHost.protocol';
import URI from 'vs/base/common/uri';
import { ThemeIcon } from 'vs/workbench/api/node/extHostTypes';

const backButton: QuickInputButton = { iconPath: 'back.svg' };
import { ThemeIcon, QuickInputButtons } from 'vs/workbench/api/node/extHostTypes';

export type Item = string | QuickPickItem;

Expand Down Expand Up @@ -153,8 +151,6 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {

// ---- QuickInput

backButton = backButton;

createQuickPick<T extends QuickPickItem>(extensionId: string): QuickPick<T> {
const session = new ExtHostQuickPick(this._proxy, extensionId, () => this._sessions.delete(session._id));
this._sessions.set(session._id, session);
Expand Down Expand Up @@ -328,14 +324,14 @@ class ExtHostQuickInput implements QuickInput {
this._buttons = buttons.slice();
this._handlesToButtons.clear();
buttons.forEach((button, i) => {
const handle = button === backButton ? -1 : i;
const handle = button === QuickInputButtons.Back ? -1 : i;
this._handlesToButtons.set(handle, button);
});
this.update({
buttons: buttons.map<TransferQuickInputButton>((button, i) => ({
iconPath: getIconUris(button.iconPath),
tooltip: button.tooltip,
handle: button === backButton ? -1 : i,
handle: button === QuickInputButtons.Back ? -1 : i,
}))
});
}
Expand Down
7 changes: 7 additions & 0 deletions src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1956,3 +1956,10 @@ export enum CommentThreadCollapsibleState {
*/
Expanded = 1
}

export class QuickInputButtons {

static readonly Back: vscode.QuickInputButton = { iconPath: 'back.svg' };

private constructor() { }
}

0 comments on commit 1b675ac

Please sign in to comment.