Skip to content

Commit 2839ea0

Browse files
committed
get it to work
1 parent 594a4f1 commit 2839ea0

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings';
1111
import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode';
1212
import { localize } from 'vs/nls';
1313
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
14-
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
14+
import { IKeybindingService, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
1515
import { AccessibilityHelpAction, AccessibleViewAction, registerAccessibilityConfiguration } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
1616
import * as strings from 'vs/base/common/strings';
1717
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -27,6 +27,7 @@ import { getNotificationFromContext } from 'vs/workbench/browser/parts/notificat
2727
import { IListService, WorkbenchList } from 'vs/platform/list/browser/listService';
2828
import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys';
2929
import { IAccessibleViewService, AccessibleViewService, IAccessibleContentProvider, IAccessibleViewOptions, AccessibleViewType } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
30+
import { KeyCode } from 'vs/base/common/keyCodes';
3031

3132
registerAccessibilityConfiguration();
3233
registerSingleton(IAccessibleViewService, AccessibleViewService, InstantiationType.Delayed);
@@ -158,11 +159,12 @@ class NotificationAccessibleViewContribution extends Disposable {
158159
const listService = accessor.get(IListService);
159160
const commandService = accessor.get(ICommandService);
160161

161-
function show(): boolean {
162+
function renderAccessibleView(): boolean {
162163
const notification = getNotificationFromContext(listService);
163164
if (!notification) {
164165
return false;
165166
}
167+
commandService.executeCommand('notifications.showList');
166168
let notificationIndex: number | undefined;
167169
const list = listService.lastFocusedList;
168170
if (list instanceof WorkbenchList) {
@@ -171,16 +173,38 @@ class NotificationAccessibleViewContribution extends Disposable {
171173
if (notificationIndex === undefined) {
172174
return false;
173175
}
176+
function focusList(): void {
177+
commandService.executeCommand('notifications.showList');
178+
if (list && notificationIndex !== undefined) {
179+
list.domFocus();
180+
try {
181+
list.setFocus([notificationIndex]);
182+
} catch { }
183+
}
184+
}
185+
const message = notification.message.original.toString();
186+
if (!message) {
187+
return false;
188+
}
174189
accessibleViewService.show({
175190
provideContent: () => {
176-
return localize('notification.accessibleView', '{0} Source: {1}', notification.message.original.toString() || '', notification.source);
191+
return localize('notification.accessibleView', '{0} Source: {1}', message, notification.source);
177192
},
178193
onClose(): void {
179-
// The notification list might have hidden depending on the elapsed time, so show it.
180-
commandService.executeCommand('notifications.showList');
181-
if (list && notificationIndex !== undefined) {
182-
list.domFocus();
183-
list.setFocus([notificationIndex]);
194+
focusList();
195+
},
196+
onKeyDown(e: IKeyboardEvent): void {
197+
if (!list) {
198+
return;
199+
}
200+
if (e.altKey && e.keyCode === KeyCode.BracketRight) {
201+
focusList();
202+
list.focusNext();
203+
renderAccessibleView();
204+
} else if (e.altKey && e.keyCode === KeyCode.BracketLeft) {
205+
focusList();
206+
list.focusPrevious();
207+
renderAccessibleView();
184208
}
185209
},
186210
verbositySettingKey: 'notifications',
@@ -191,7 +215,7 @@ class NotificationAccessibleViewContribution extends Disposable {
191215
});
192216
return true;
193217
}
194-
return show();
218+
return renderAccessibleView();
195219
}, NotificationFocusedContext));
196220
}
197221
}

0 commit comments

Comments
 (0)