mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
add proposed API for short and long variant of LanguageStatusItem#text
(#195141)
* add proposed API for short and long variant of `LanguageStatusItem#text` https://github.com/microsoft/vscode/issues/192880 * add new proposal to allow list
This commit is contained in:
parent
b282108c4b
commit
a383c1601d
|
@ -28,6 +28,7 @@
|
|||
"portsAttributes",
|
||||
"quickPickSortByLabel",
|
||||
"readonlyMessage",
|
||||
"languageStatusText",
|
||||
"resolvers",
|
||||
"saveEditor",
|
||||
"scmActionButton",
|
||||
|
@ -44,7 +45,7 @@
|
|||
"textSearchProvider",
|
||||
"timeline",
|
||||
"tokenInformation",
|
||||
"treeViewActiveItem",
|
||||
"treeViewActiveItem",
|
||||
"treeViewReveal",
|
||||
"workspaceTrust",
|
||||
"telemetry",
|
||||
|
|
|
@ -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<vscode.LanguageStatusItem, 'dispose'> = {
|
||||
const data: Omit<vscode.LanguageStatusItem, 'dispose' | 'text2'> = {
|
||||
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;
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
12
src/vscode-dts/vscode.proposed.languageStatusText.d.ts
vendored
Normal file
12
src/vscode-dts/vscode.proposed.languageStatusText.d.ts
vendored
Normal file
|
@ -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 };
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue