mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Merge pull request #195585 from microsoft/merogge/saved
add saved alert, audio cue
This commit is contained in:
commit
ab51ad15e3
|
@ -5,33 +5,55 @@
|
|||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IAccessibilityService, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
|
||||
import { AccessibleNotificationEvent, IAccessibilityService, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { AudioCue, IAudioCueService, Sound } from 'vs/platform/audioCues/browser/audioCueService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class AccessibleNotificationService extends Disposable implements IAccessibleNotificationService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private _events: Map<AccessibleNotificationEvent, { audioCue: AudioCue; alertMessage: string }> = new Map();
|
||||
constructor(
|
||||
@IAudioCueService private readonly _audioCueService: IAudioCueService,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService) {
|
||||
super();
|
||||
this._events.set(AccessibleNotificationEvent.Clear, { audioCue: AudioCue.clear, alertMessage: localize('cleared', "Cleared") });
|
||||
this._events.set(AccessibleNotificationEvent.Save, { audioCue: AudioCue.save, alertMessage: localize('saved', "Saved") });
|
||||
}
|
||||
|
||||
notifyCleared(): void {
|
||||
const audioCueValue = this._configurationService.getValue(AudioCue.clear.settingsKey);
|
||||
notify(event: AccessibleNotificationEvent): void {
|
||||
const { audioCue, alertMessage } = this._events.get(event)!;
|
||||
const audioCueValue = this._configurationService.getValue(audioCue.settingsKey);
|
||||
if (audioCueValue === 'on' || audioCueValue === 'auto' && this._accessibilityService.isScreenReaderOptimized()) {
|
||||
this._audioCueService.playAudioCue(AudioCue.clear);
|
||||
this._audioCueService.playAudioCue(audioCue);
|
||||
} else {
|
||||
alert(localize('cleared', "Cleared"));
|
||||
this._accessibilityService.alert(alertMessage);
|
||||
}
|
||||
}
|
||||
|
||||
notifySaved(userGesture: boolean): void {
|
||||
const { audioCue, alertMessage } = this._events.get(AccessibleNotificationEvent.Save)!;
|
||||
const alertSetting: NotificationSetting = this._configurationService.getValue('accessibility.alert.save');
|
||||
if (this._shouldNotify(alertSetting, userGesture)) {
|
||||
this._accessibilityService.alert(alertMessage);
|
||||
}
|
||||
const audioCueSetting: NotificationSetting = this._configurationService.getValue(audioCue.settingsKey);
|
||||
if (this._shouldNotify(audioCueSetting, userGesture)) {
|
||||
// Play sound bypasses the usual audio cue checks IE screen reader optimized, auto, etc.
|
||||
this._audioCueService.playSound(Sound.save, true);
|
||||
}
|
||||
}
|
||||
|
||||
private _shouldNotify(settingValue: NotificationSetting, userGesture: boolean): boolean {
|
||||
return settingValue === 'always' || settingValue === 'userGesture' && userGesture;
|
||||
}
|
||||
}
|
||||
type NotificationSetting = 'never' | 'always' | 'userGesture';
|
||||
|
||||
export class TestAccessibleNotificationService extends Disposable implements IAccessibleNotificationService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
notifyCleared(): void { }
|
||||
notify(event: AccessibleNotificationEvent): void { }
|
||||
notifySaved(userGesture: boolean): void { }
|
||||
}
|
||||
|
|
|
@ -55,6 +55,12 @@ export const IAccessibleNotificationService = createDecorator<IAccessibleNotific
|
|||
*/
|
||||
export interface IAccessibleNotificationService {
|
||||
readonly _serviceBrand: undefined;
|
||||
notifyCleared(): void;
|
||||
notify(event: AccessibleNotificationEvent): void;
|
||||
notifySaved(userGesture: boolean): void;
|
||||
}
|
||||
|
||||
export const enum AccessibleNotificationEvent {
|
||||
Clear = 'clear',
|
||||
Save = 'save',
|
||||
Format = 'format'
|
||||
}
|
||||
|
|
|
@ -255,6 +255,7 @@ export class Sound {
|
|||
public static readonly chatResponseReceived3 = Sound.register({ fileName: 'chatResponseReceived3.mp3' });
|
||||
public static readonly chatResponseReceived4 = Sound.register({ fileName: 'chatResponseReceived4.mp3' });
|
||||
public static readonly clear = Sound.register({ fileName: 'clear.mp3' });
|
||||
public static readonly save = Sound.register({ fileName: 'save.mp3' });
|
||||
|
||||
private constructor(public readonly fileName: string) { }
|
||||
}
|
||||
|
@ -426,6 +427,12 @@ export class AudioCue {
|
|||
settingsKey: 'audioCues.clear'
|
||||
});
|
||||
|
||||
public static readonly save = AudioCue.register({
|
||||
name: localize('audioCues.save', 'Save'),
|
||||
sound: Sound.save,
|
||||
settingsKey: 'audioCues.save'
|
||||
});
|
||||
|
||||
private constructor(
|
||||
public readonly sound: SoundSource,
|
||||
public readonly name: string,
|
||||
|
|
BIN
src/vs/platform/audioCues/browser/media/save.mp3
Normal file
BIN
src/vs/platform/audioCues/browser/media/save.mp3
Normal file
Binary file not shown.
|
@ -14,6 +14,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
|
|||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IWorkingCopy, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
export class EditorAutoSave extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
|
@ -32,7 +33,8 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
|
|||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
|
||||
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IAccessibleNotificationService private readonly _accessibleNotificationService: IAccessibleNotificationService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -196,7 +198,7 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
|
|||
// Save if dirty
|
||||
if (workingCopy.isDirty()) {
|
||||
this.logService.trace(`[editor auto save] running auto save`, workingCopy.resource.toString(), workingCopy.typeId);
|
||||
|
||||
this._accessibleNotificationService.notifySaved(false);
|
||||
workingCopy.save({ reason: SaveReason.AUTO });
|
||||
}
|
||||
}, this.autoSaveAfterDelay);
|
||||
|
|
|
@ -47,6 +47,10 @@ export const enum AccessibilityVerbositySettingId {
|
|||
Comments = 'accessibility.verbosity.comments'
|
||||
}
|
||||
|
||||
export const enum AccessibilityAlertSettingId {
|
||||
Save = 'accessibility.alert.save'
|
||||
}
|
||||
|
||||
export const enum AccessibleViewProviderId {
|
||||
Terminal = 'terminal',
|
||||
TerminalHelp = 'terminal-help',
|
||||
|
@ -117,7 +121,19 @@ const configuration: IConfigurationNode = {
|
|||
[AccessibilityVerbositySettingId.Comments]: {
|
||||
description: localize('verbosity.comments', 'Provide information about actions that can be taken in the comment widget or in a file which contains comments.'),
|
||||
...baseProperty
|
||||
}
|
||||
},
|
||||
[AccessibilityAlertSettingId.Save]: {
|
||||
'markdownDescription': localize('alert.save', "When in screen reader mode, alerts when a file is saved. Also see {0}", '`#audioCues.save#`'),
|
||||
'type': 'string',
|
||||
'enum': ['userGesture', 'always', 'never'],
|
||||
'default': 'never',
|
||||
'enumDescriptions': [
|
||||
localize('alert.save.userGesture', "Alerts when a file is saved via user gesture."),
|
||||
localize('alert.save.always', "Alerts whenever is a file is saved, including auto save."),
|
||||
localize('alert.save.never', "Never alerts.")
|
||||
],
|
||||
tags: ['accessibility']
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -137,6 +137,18 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
|
|||
...audioCueFeatureBase,
|
||||
default: 'off'
|
||||
},
|
||||
'audioCues.save': {
|
||||
'markdownDescription': localize('audioCues.save', "Plays a sound when a file is saved. Also see {0}", '`#accessibility.alert.save#`'),
|
||||
'type': 'string',
|
||||
'enum': ['userGesture', 'always', 'never'],
|
||||
'default': 'never',
|
||||
'enumDescriptions': [
|
||||
localize('audioCues.enabled.userGesture', "Plays the audio cue when a user explicitly saves a file."),
|
||||
localize('audioCues.enabled.always', "Plays the audio cue whenever a file is saved, including auto save."),
|
||||
localize('audioCues.enabled.never', "Never plays the audio cue.")
|
||||
],
|
||||
tags: ['accessibility']
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Codicon } from 'vs/base/common/codicons';
|
|||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { Action2, IAction2Options, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
@ -118,5 +118,5 @@ export function getClearAction(viewId: string, providerId: string) {
|
|||
}
|
||||
|
||||
function announceChatCleared(accessor: ServicesAccessor): void {
|
||||
accessor.get(IAccessibleNotificationService).notifyCleared();
|
||||
accessor.get(IAccessibleNotificationService).notify(AccessibleNotificationEvent.Clear);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ import { Variable } from 'vs/workbench/contrib/debug/common/debugModel';
|
|||
import { ReplEvaluationResult, ReplGroup } from 'vs/workbench/contrib/debug/common/replModel';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
|
@ -978,7 +978,7 @@ registerAction2(class extends ViewAction<Repl> {
|
|||
runInView(_accessor: ServicesAccessor, view: Repl): void {
|
||||
const accessibleNotificationService = _accessor.get(IAccessibleNotificationService);
|
||||
view.clearRepl();
|
||||
accessibleNotificationService.notifyCleared();
|
||||
accessibleNotificationService.notify(AccessibleNotificationEvent.Clear);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import { DEFAULT_EDITOR_ASSOCIATION } from 'vs/workbench/common/editor';
|
|||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { TestAccessibleNotificationService } from 'vs/platform/accessibility/browser/accessibleNotificationService';
|
||||
|
||||
suite('EditorAutoSave', () => {
|
||||
|
||||
|
@ -42,7 +44,7 @@ suite('EditorAutoSave', () => {
|
|||
const configurationService = new TestConfigurationService();
|
||||
configurationService.setUserConfiguration('files', autoSaveConfig);
|
||||
instantiationService.stub(IConfigurationService, configurationService);
|
||||
|
||||
instantiationService.stub(IAccessibleNotificationService, disposables.add(new TestAccessibleNotificationService()));
|
||||
instantiationService.stub(IFilesConfigurationService, disposables.add(new TestFilesConfigurationService(
|
||||
<IContextKeyService>instantiationService.createInstance(MockContextKeyService),
|
||||
configurationService,
|
||||
|
|
|
@ -28,7 +28,7 @@ import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
|
|||
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
|
||||
import { Disposable, dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
// Register Service
|
||||
registerSingleton(IOutputService, OutputService, InstantiationType.Delayed);
|
||||
|
@ -225,7 +225,7 @@ class OutputContribution extends Disposable implements IWorkbenchContribution {
|
|||
const activeChannel = outputService.getActiveChannel();
|
||||
if (activeChannel) {
|
||||
activeChannel.clear();
|
||||
accessibleNotificationService.notifyCleared();
|
||||
accessibleNotificationService.notify(AccessibleNotificationEvent.Clear);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -43,7 +43,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
|
|||
import { debounce } from 'vs/base/common/decorators';
|
||||
import { MouseWheelClassifier } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { IMouseWheelEvent, StandardWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { AccessibleNotificationEvent, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
const enum RenderConstants {
|
||||
/**
|
||||
|
@ -590,7 +590,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
|
|||
// the prompt being written
|
||||
this._capabilities.get(TerminalCapability.CommandDetection)?.handlePromptStart();
|
||||
this._capabilities.get(TerminalCapability.CommandDetection)?.handleCommandStart();
|
||||
this._accessibleNotificationService.notifyCleared();
|
||||
this._accessibleNotificationService.notify(AccessibleNotificationEvent.Clear);
|
||||
}
|
||||
|
||||
hasSelection(): boolean {
|
||||
|
|
|
@ -33,6 +33,7 @@ import { IWorkspaceTrustRequestService, WorkspaceTrustUriResponse } from 'vs/pla
|
|||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { findGroup } from 'vs/workbench/services/editor/common/editorGroupFinder';
|
||||
import { ITextEditorService } from 'vs/workbench/services/textfile/common/textEditorService';
|
||||
import { IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
|
||||
|
@ -70,7 +71,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||
@IEditorResolverService private readonly editorResolverService: IEditorResolverService,
|
||||
@IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService,
|
||||
@IHostService private readonly hostService: IHostService,
|
||||
@ITextEditorService private readonly textEditorService: ITextEditorService
|
||||
@ITextEditorService private readonly textEditorService: ITextEditorService,
|
||||
@IAccessibleNotificationService private readonly accessibleNotificationService: IAccessibleNotificationService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -972,9 +974,12 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const success = saveResults.every(result => !!result);
|
||||
if (success) {
|
||||
this.accessibleNotificationService.notifySaved(options?.reason === SaveReason.EXPLICIT);
|
||||
}
|
||||
return {
|
||||
success: saveResults.every(result => !!result),
|
||||
success,
|
||||
editors: coalesce(saveResults)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
|
|||
import { IWorkingCopyService, WorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IWorkingCopy, IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { IAccessibilityService, IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||
import { BrowserTextFileService } from 'vs/workbench/services/textfile/browser/browserTextFileService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
@ -166,6 +166,7 @@ import { IHoverOptions, IHoverService, IHoverWidget } from 'vs/workbench/service
|
|||
import { IRemoteExtensionsScannerService } from 'vs/platform/remote/common/remoteExtensionsScanner';
|
||||
import { IRemoteSocketFactoryService, RemoteSocketFactoryService } from 'vs/platform/remote/common/remoteSocketFactoryService';
|
||||
import { EditorParts } from 'vs/workbench/browser/parts/editor/editorParts';
|
||||
import { TestAccessibleNotificationService } from 'vs/platform/accessibility/browser/accessibleNotificationService';
|
||||
|
||||
export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined, undefined);
|
||||
|
@ -274,6 +275,8 @@ export function workbenchInstantiationService(
|
|||
instantiationService.stub(IDialogService, new TestDialogService());
|
||||
const accessibilityService = new TestAccessibilityService();
|
||||
instantiationService.stub(IAccessibilityService, accessibilityService);
|
||||
const accessibleNotificationService = disposables.add(new TestAccessibleNotificationService());
|
||||
instantiationService.stub(IAccessibleNotificationService, accessibleNotificationService);
|
||||
instantiationService.stub(IFileDialogService, instantiationService.createInstance(TestFileDialogService));
|
||||
instantiationService.stub(ILanguageService, disposables.add(instantiationService.createInstance(LanguageService)));
|
||||
instantiationService.stub(ILanguageFeaturesService, new LanguageFeaturesService());
|
||||
|
|
Loading…
Reference in a new issue