diff --git a/extensions/json-language-features/client/src/jsonMain.ts b/extensions/json-language-features/client/src/jsonMain.ts index 291889faad9..1f51b66733d 100644 --- a/extensions/json-language-features/client/src/jsonMain.ts +++ b/extensions/json-language-features/client/src/jsonMain.ts @@ -83,7 +83,12 @@ export function activate(context: ExtensionContext) { let documentSelector = ['json', 'jsonc']; - let schemaResolutionErrorStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 0); + let schemaResolutionErrorStatusBarItem = window.createStatusBarItem({ + id: 'status.json.resolveError', + name: localize('json.resolveError', "JSON: Schema Resolution Error"), + alignment: StatusBarAlignment.Right, + priority: 0 + }); schemaResolutionErrorStatusBarItem.command = '_json.retryResolveSchema'; schemaResolutionErrorStatusBarItem.tooltip = localize('json.schemaResolutionErrorMessage', 'Unable to resolve schema.') + ' ' + localize('json.clickToRetry', 'Click to retry.'); schemaResolutionErrorStatusBarItem.text = '$(alert)'; diff --git a/extensions/typescript-language-features/src/utils/projectStatus.ts b/extensions/typescript-language-features/src/utils/projectStatus.ts index 4eb9b8c7686..15aa72a80d0 100644 --- a/extensions/typescript-language-features/src/utils/projectStatus.ts +++ b/extensions/typescript-language-features/src/utils/projectStatus.ts @@ -23,7 +23,12 @@ class ExcludeHintItem { constructor( private readonly telemetryReporter: TelemetryReporter ) { - this._item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 98 /* to the right of typescript version status (99) */); + this._item = vscode.window.createStatusBarItem({ + id: 'status.typescript.exclude', + name: localize('statusExclude', "TypeScript: Configure Excludes"), + alignment: vscode.StatusBarAlignment.Right, + priority: 98 /* to the right of typescript version status (99) */ + }); this._item.command = 'js.projectStatus.command'; } diff --git a/extensions/typescript-language-features/src/utils/versionStatus.ts b/extensions/typescript-language-features/src/utils/versionStatus.ts index 0b3e3412617..07bd2e5921a 100644 --- a/extensions/typescript-language-features/src/utils/versionStatus.ts +++ b/extensions/typescript-language-features/src/utils/versionStatus.ts @@ -7,6 +7,9 @@ import * as vscode from 'vscode'; import * as languageModeIds from './languageModeIds'; import { TypeScriptVersion } from './versionProvider'; import { Disposable } from './dispose'; +import * as nls from 'vscode-nls'; + +const localize = nls.loadMessageBundle(); export default class VersionStatus extends Disposable { private readonly _versionBarEntry: vscode.StatusBarItem; @@ -15,7 +18,12 @@ export default class VersionStatus extends Disposable { private readonly _normalizePath: (resource: vscode.Uri) => string | undefined ) { super(); - this._versionBarEntry = this._register(vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 99 /* to the right of editor status (100) */)); + this._versionBarEntry = this._register(vscode.window.createStatusBarItem({ + id: 'status.typescript.version', + name: localize('typescriptVersion', "TypeScript: Version"), + alignment: vscode.StatusBarAlignment.Right, + priority: 99 /* to the right of editor status (100) */ + })); vscode.window.onDidChangeActiveTextEditor(this.showHideStatus, this, this._disposables); } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 317a06d6a5b..7aad5441466 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1436,4 +1436,53 @@ declare module 'vscode' { } // #endregion + + + // #region Ben - status bar item with ID and Name + + export namespace window { + + /** + * Options to configure the status bar item. + */ + export interface StatusBarItemOptions { + + /** + * A unique identifier of the status bar item. The identifier + * is for example used to allow a user to show or hide the + * status bar item in the UI. + */ + id: string; + + /** + * A human readable name of the status bar item. The name is + * for example used as a label in the UI to show or hide the + * status bar item. + */ + name: string; + + /** + * The alignment of the status bar item. + */ + alignment?: StatusBarAlignment; + + /** + * The priority of the status bar item. Higher value means the item should + * be shown more to the left. + */ + priority?: number; + } + + /** + * Creates a status bar [item](#StatusBarItem). + * + * @param options The options of the item. If not provided, some default values + * will be assumed. For example, the `StatusBarItemOptions.id` will be the id + * of the extension and the `StatusBarItemOptions.name` will be the extension name. + * @return A new status bar item. + */ + export function createStatusBarItem(options?: StatusBarItemOptions): StatusBarItem; + } + + //#endregion } diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index dc6f2cd2e16..6944f8e767e 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -465,11 +465,24 @@ export function createApiFactory( showSaveDialog(options) { return extHostDialogs.showSaveDialog(options); }, - createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem { - const id = extension.identifier.value; - const name = nls.localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name); + createStatusBarItem(alignmentOrOptions?: vscode.StatusBarAlignment | vscode.window.StatusBarItemOptions, priority?: number): vscode.StatusBarItem { + let id: string; + let name: string; + let alignment: number | undefined; - return extHostStatusBar.createStatusBarEntry(id, name, position, priority); + if (alignmentOrOptions && typeof alignmentOrOptions !== 'number') { + id = alignmentOrOptions.id; + name = alignmentOrOptions.name; + alignment = alignmentOrOptions.alignment; + priority = alignmentOrOptions.priority; + } else { + id = extension.identifier.value; + name = nls.localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name); + alignment = alignmentOrOptions; + priority = priority; + } + + return extHostStatusBar.createStatusBarEntry(id, name, alignment, priority); }, setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable): vscode.Disposable { return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);