Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle alerts in audio cue service, add List Alerts command and settings #201833

Merged
merged 24 commits into from Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/vs/editor/common/standaloneStrings.ts
Expand Up @@ -25,12 +25,8 @@ export namespace AccessibilityHelpNLS {
export const tabFocusModeOffMsg = nls.localize("tabFocusModeOffMsg", "Pressing Tab in the current editor will insert the tab character. Toggle this behavior {0}.");
export const tabFocusModeOffMsgNoKb = nls.localize("tabFocusModeOffMsgNoKb", "Pressing Tab in the current editor will insert the tab character. The command {0} is currently not triggerable by a keybinding.");
export const showAccessibilityHelpAction = nls.localize("showAccessibilityHelpAction", "Show Accessibility Help");
export const saveAudioCueDisabled = nls.localize("saveAudioCueDisabled", "`audioCues.save` is disabled, so an alert will occur when a file is saved.");
export const saveAudioCueAlways = nls.localize("saveAudioCueAlways", "`audioCues.save` is enabled, so will play whenever a file is saved.");
export const saveAudioCueUserGesture = nls.localize("saveAudioCueUserGesture", "`audioCues.save` is enabled, so will play when a file is saved via user gesture.");
export const formatAudioCueDisabled = nls.localize("formatAudioCueDisabled", "`audioCues.format` is disabled, so an alert will occur when a file is formatted.");
export const formatAudioCueAlways = nls.localize("formatAudioCueAlways", "`audioCues.format` is enabled, so will play whenever a file is formatted.");
export const formatAudioCueUserGesture = nls.localize("formatAudioCueUserGesture", "`audioCues.format` is enabled, so will play when a file is formatted via user gesture.");
export const listAudioCues = nls.localize("listAudioCuesCommand", "Run the command: List Audio Cues for an overview of all audio cues and their current status.");
export const listAlerts = nls.localize("listAlertsCommand", "Run the command: List Alerts for an overview of alerts and their current status.");
}

export namespace InspectTokensNLS {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/editor/contrib/format/browser/format.ts
Expand Up @@ -30,7 +30,7 @@ import { IProgress } from 'vs/platform/progress/common/progress';
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
import { LanguageFeatureRegistry } from 'vs/editor/common/languageFeatureRegistry';
import { ILogService } from 'vs/platform/log/common/log';
import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';

export function getRealAndSyntheticDocumentFormattersOrdered(
documentFormattingEditProvider: LanguageFeatureRegistry<DocumentFormattingEditProvider>,
Expand Down Expand Up @@ -135,7 +135,7 @@ export async function formatDocumentRangesWithProvider(
): Promise<boolean> {
const workerService = accessor.get(IEditorWorkerService);
const logService = accessor.get(ILogService);
const accessibleNotificationService = accessor.get(IAccessibleNotificationService);
const audioCueService = accessor.get(IAudioCueService);

let model: ITextModel;
let cts: CancellationTokenSource;
Expand Down Expand Up @@ -279,7 +279,7 @@ export async function formatDocumentRangesWithProvider(
return null;
});
}
accessibleNotificationService.notify(AccessibleNotificationEvent.Format, userGesture);
audioCueService.playAudioCue(AudioCue.format, { userGesture });
return true;
}

Expand Down Expand Up @@ -312,7 +312,7 @@ export async function formatDocumentWithProvider(
userGesture?: boolean
): Promise<boolean> {
const workerService = accessor.get(IEditorWorkerService);
const accessibleNotificationService = accessor.get(IAccessibleNotificationService);
const audioCueService = accessor.get(IAudioCueService);

let model: ITextModel;
let cts: CancellationTokenSource;
Expand Down Expand Up @@ -373,7 +373,7 @@ export async function formatDocumentWithProvider(
return null;
});
}
accessibleNotificationService.notify(AccessibleNotificationEvent.Format, userGesture);
audioCueService.playAudioCue(AudioCue.format, { userGesture });
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/contrib/format/browser/formatActions.ts
Expand Up @@ -21,7 +21,7 @@ import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeat
import { formatDocumentRangesWithSelectedProvider, formatDocumentWithSelectedProvider, FormattingMode, getOnTypeFormattingEdits } from 'vs/editor/contrib/format/browser/format';
import { FormattingEdit } from 'vs/editor/contrib/format/browser/formattingEdit';
import * as nls from 'vs/nls';
import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
Expand All @@ -40,7 +40,7 @@ export class FormatOnType implements IEditorContribution {
private readonly _editor: ICodeEditor,
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
@IEditorWorkerService private readonly _workerService: IEditorWorkerService,
@IAccessibleNotificationService private readonly _accessibleNotificationService: IAccessibleNotificationService
@IAudioCueService private readonly _audioCueService: IAudioCueService
) {
this._disposables.add(_languageFeaturesService.onTypeFormattingEditProvider.onDidChange(this._update, this));
this._disposables.add(_editor.onDidChangeModel(() => this._update()));
Expand Down Expand Up @@ -143,7 +143,7 @@ export class FormatOnType implements IEditorContribution {
return;
}
if (isNonEmptyArray(edits)) {
this._accessibleNotificationService.notify(AccessibleNotificationEvent.Format, false);
this._audioCueService.playAudioCue(AudioCue.format, { userGesture: false });
FormattingEdit.execute(this._editor, edits, true);
}
}).finally(() => {
Expand Down
17 changes: 6 additions & 11 deletions src/vs/editor/standalone/browser/standaloneServices.ts
Expand Up @@ -71,7 +71,7 @@ import { StandaloneQuickInputService } from 'vs/editor/standalone/browser/quickI
import { StandaloneThemeService } from 'vs/editor/standalone/browser/standaloneThemeService';
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneTheme';
import { AccessibilityService } from 'vs/platform/accessibility/browser/accessibilityService';
import { AccessibleNotificationEvent, IAccessibilityService, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IMenuService } from 'vs/platform/actions/common/actions';
import { MenuService } from 'vs/platform/actions/common/menuService';
import { BrowserClipboardService } from 'vs/platform/clipboard/browser/clipboardService';
Expand Down Expand Up @@ -1059,7 +1059,11 @@ class StandaloneAudioService implements IAudioCueService {
async playAudioCues(cues: AudioCue[]): Promise<void> {
}

isEnabled(cue: AudioCue): boolean {
isCueEnabled(cue: AudioCue): boolean {
return false;
}

isAlertEnabled(cue: AudioCue): boolean {
return false;
}

Expand All @@ -1074,14 +1078,6 @@ class StandaloneAudioService implements IAudioCueService {
}
}

class StandaloneAccessibleNotificationService implements IAccessibleNotificationService {
_serviceBrand: undefined;

notify(event: AccessibleNotificationEvent, userGesture?: boolean | undefined): void {
// NOOP
}
}

export interface IEditorOverrideServices {
[index: string]: any;
}
Expand Down Expand Up @@ -1120,7 +1116,6 @@ registerSingleton(IClipboardService, BrowserClipboardService, InstantiationType.
registerSingleton(IContextMenuService, StandaloneContextMenuService, InstantiationType.Eager);
registerSingleton(IMenuService, MenuService, InstantiationType.Eager);
registerSingleton(IAudioCueService, StandaloneAudioService, InstantiationType.Eager);
registerSingleton(IAccessibleNotificationService, StandaloneAccessibleNotificationService, InstantiationType.Eager);

/**
* We don't want to eagerly instantiate services because embedders get a one time chance
Expand Down
16 changes: 0 additions & 16 deletions src/vs/platform/accessibility/common/accessibility.ts
Expand Up @@ -47,19 +47,3 @@ export function isAccessibilityInformation(obj: any): obj is IAccessibilityInfor
&& (typeof obj.role === 'undefined' || typeof obj.role === 'string');
}

export const IAccessibleNotificationService = createDecorator<IAccessibleNotificationService>('accessibleNotificationService');
/**
* Manages whether an audio cue or an aria alert will be used
* in response to actions taken around the workbench.
* Targets screen reader and braille users.
*/
export interface IAccessibleNotificationService {
readonly _serviceBrand: undefined;
notify(event: AccessibleNotificationEvent, userGesture?: boolean): void;
}

export const enum AccessibleNotificationEvent {
Clear = 'clear',
Save = 'save',
Format = 'format'
}