diff --git a/extensions/vscode-api-tests/package.json b/extensions/vscode-api-tests/package.json index 65fa4206149b5..1f96c1e533c5d 100644 --- a/extensions/vscode-api-tests/package.json +++ b/extensions/vscode-api-tests/package.json @@ -28,6 +28,7 @@ "portsAttributes", "quickPickSortByLabel", "readonlyMessage", + "languageStatusText", "resolvers", "saveEditor", "scmActionButton", @@ -44,7 +45,7 @@ "textSearchProvider", "timeline", "tokenInformation", - "treeViewActiveItem", + "treeViewActiveItem", "treeViewReveal", "workspaceTrust", "telemetry", diff --git a/src/vs/workbench/api/common/extHostLanguages.ts b/src/vs/workbench/api/common/extHostLanguages.ts index c56e3340760b1..78c5be8415e70 100644 --- a/src/vs/workbench/api/common/extHostLanguages.ts +++ b/src/vs/workbench/api/common/extHostLanguages.ts @@ -14,6 +14,7 @@ import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { CommandsConverter } from 'vs/workbench/api/common/extHostCommands'; import { IURITransformer } from 'vs/base/common/uriIpc'; +import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions'; export class ExtHostLanguages implements ExtHostLanguagesShape { @@ -90,7 +91,7 @@ export class ExtHostLanguages implements ExtHostLanguagesShape { } ids.add(fullyQualifiedId); - const data: Omit = { + const data: Omit = { selector, id, name: extension.displayName ?? extension.name, @@ -160,6 +161,15 @@ export class ExtHostLanguages implements ExtHostLanguagesShape { data.text = value; updateAsync(); }, + set text2(value) { + checkProposedApiEnabled(extension, 'languageStatusText'); + data.text = value; + updateAsync(); + }, + get text2() { + checkProposedApiEnabled(extension, 'languageStatusText'); + return data.text; + }, get detail() { return data.detail; }, diff --git a/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.ts b/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.ts index c5900bbf72182..b2af996d57e02 100644 --- a/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.ts +++ b/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.ts @@ -30,6 +30,7 @@ import { URI } from 'vs/base/common/uri'; import { Action2, registerAction2 } from 'vs/platform/actions/common/actions'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { Categories } from 'vs/platform/action/common/actionCommonCategories'; +import { IAccessibilityInformation } from 'vs/platform/accessibility/common/accessibility'; class LanguageStatusViewModel { @@ -182,7 +183,7 @@ class EditorStatusContribution implements IWorkbenchContribution { for (const status of model.combined) { const isPinned = model.dedicated.includes(status); element.appendChild(this._renderStatus(status, showSeverity, isPinned, this._renderDisposables)); - ariaLabels.push(this._asAriaLabel(status)); + ariaLabels.push(EditorStatusContribution._accessibilityInformation(status).label); isOneBusy = isOneBusy || (!isPinned && status.busy); // unpinned items contribute to the busy-indicator of the composite status item } const props: IStatusbarEntry = { @@ -275,7 +276,8 @@ class EditorStatusContribution implements IWorkbenchContribution { const label = document.createElement('span'); label.classList.add('label'); - dom.append(label, ...renderLabelWithIcons(status.busy ? `$(sync~spin)\u00A0\u00A0${status.label}` : status.label)); + const labelValue = typeof status.label === 'string' ? status.label : status.label.value; + dom.append(label, ...renderLabelWithIcons(status.busy ? `$(sync~spin)\u00A0\u00A0${labelValue}` : labelValue)); left.appendChild(label); const detail = document.createElement('span'); @@ -351,13 +353,15 @@ class EditorStatusContribution implements IWorkbenchContribution { } } - private _asAriaLabel(status: ILanguageStatus): string { + private static _accessibilityInformation(status: ILanguageStatus): IAccessibilityInformation { if (status.accessibilityInfo) { - return status.accessibilityInfo.label; - } else if (status.detail) { - return localize('aria.1', '{0}, {1}', status.label, status.detail); + return status.accessibilityInfo; + } + const textValue = typeof status.label === 'string' ? status.label : status.label.value; + if (status.detail) { + return { label: localize('aria.1', '{0}, {1}', textValue, status.detail) }; } else { - return localize('aria.2', '{0}', status.label); + return { label: localize('aria.2', '{0}', textValue) }; } } @@ -372,10 +376,12 @@ class EditorStatusContribution implements IWorkbenchContribution { kind = 'error'; } + const textValue = typeof item.label === 'string' ? item.label : item.label.shortValue; + return { name: localize('name.pattern', '{0} (Language Status)', item.name), - text: item.busy ? `${item.label}\u00A0\u00A0$(sync~spin)` : item.label, - ariaLabel: item.accessibilityInfo?.label ?? item.label, + text: item.busy ? `${textValue}\u00A0\u00A0$(sync~spin)` : textValue, + ariaLabel: EditorStatusContribution._accessibilityInformation(item).label, role: item.accessibilityInfo?.role, tooltip: item.command?.tooltip || new MarkdownString(item.detail, { isTrusted: true, supportThemeIcons: true }), kind, diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 10e5e00d2ac5a..ac67c67fc86d3 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -55,6 +55,7 @@ export const allApiProposals = Object.freeze({ interactiveUserActions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveUserActions.d.ts', interactiveWindow: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveWindow.d.ts', ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts', + languageStatusText: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.languageStatusText.d.ts', mappedEditsProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.mappedEditsProvider.d.ts', notebookCellExecutionState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts', notebookControllerAffinityHidden: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts', diff --git a/src/vs/workbench/services/languageStatus/common/languageStatusService.ts b/src/vs/workbench/services/languageStatus/common/languageStatusService.ts index a7a49dad0be20..e10d2a3ef1e6b 100644 --- a/src/vs/workbench/services/languageStatus/common/languageStatusService.ts +++ b/src/vs/workbench/services/languageStatus/common/languageStatusService.ts @@ -21,7 +21,7 @@ export interface ILanguageStatus { readonly name: string; readonly selector: LanguageSelector; readonly severity: Severity; - readonly label: string; + readonly label: string | { value: string; shortValue: string }; readonly detail: string; readonly busy: boolean; readonly source: string; diff --git a/src/vscode-dts/vscode.proposed.languageStatusText.d.ts b/src/vscode-dts/vscode.proposed.languageStatusText.d.ts new file mode 100644 index 0000000000000..d6fe4854d73b0 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.languageStatusText.d.ts @@ -0,0 +1,12 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + export interface LanguageStatusItem { + + text2: string | { value: string; shortValue: string }; + } +}