Skip to content

Commit 1320f52

Browse files
committed
clean up
1 parent b7bf8b0 commit 1320f52

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,7 @@ class NotificationAccessibleViewContribution extends Disposable {
210210
}
211211
focusList();
212212
list.focusNext();
213-
if (!!notificationIndex) {
214-
const notificationNumber = notificationIndex + 1;
215-
if (!!notificationNumber && !!length && notificationNumber + 1 <= length) {
216-
alert(`Focused ${notificationNumber + 1} of ${length}`);
217-
}
218-
}
213+
alertFocusChange(notificationIndex, length, 'next');
219214
renderAccessibleView();
220215
},
221216
previous(): void {
@@ -224,12 +219,7 @@ class NotificationAccessibleViewContribution extends Disposable {
224219
}
225220
focusList();
226221
list.focusPrevious();
227-
if (!!notificationIndex) {
228-
const notificationNumber = notificationIndex + 1;
229-
if (!!notificationNumber && !!length && notificationNumber - 1 > 0) {
230-
alert(`Focused ${notificationNumber - 1} of ${length}`);
231-
}
232-
}
222+
alertFocusChange(notificationIndex, length, 'previous');
233223
renderAccessibleView();
234224
},
235225
verbositySettingKey: AccessibilityVerbositySettingId.Notification,
@@ -265,3 +255,17 @@ class AccessibleViewNavigatorContribution extends Disposable {
265255
}
266256

267257
workbenchContributionsRegistry.registerWorkbenchContribution(AccessibleViewNavigatorContribution, LifecyclePhase.Eventually);
258+
259+
export function alertFocusChange(index: number | undefined, length: number | undefined, type: 'next' | 'previous'): void {
260+
if (index === undefined || length === undefined) {
261+
return;
262+
}
263+
const number = index + 1;
264+
265+
if (type === 'next' && number + 1 > length) {
266+
alert(`Focused ${number + 1} of ${length}`);
267+
} else if (type === 'previous' && number - 1 > 0) {
268+
alert(`Focused ${number - 1} of ${length}`);
269+
}
270+
return;
271+
}

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { CONTEXT_IN_CHAT_SESSION } from 'vs/workbench/contrib/chat/common/chatCo
4444
import { ChatAccessibilityService } from 'vs/workbench/contrib/chat/browser/chatAccessibilityService';
4545
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
4646
import { QuickQuestionMode } from 'vs/workbench/contrib/chat/browser/actions/quickQuestionActions/quickQuestionAction';
47-
import { alert } from 'vs/base/browser/ui/aria/aria';
47+
import { alertFocusChange } from 'vs/workbench/contrib/accessibility/browser/accessibility.contribution';
4848

4949
// Register configuration
5050
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
@@ -193,22 +193,12 @@ class ChatAccessibleViewContribution extends Disposable {
193193
},
194194
next() {
195195
verifiedWidget.moveFocus(focusedItem, 'next');
196-
if (!!responseIndex) {
197-
const notificationNumber = responseIndex + 1;
198-
if (!!notificationNumber && !!length && notificationNumber + 1 <= length) {
199-
alert(`Focused ${notificationNumber + 1} of ${length}`);
200-
}
201-
}
196+
alertFocusChange(responseIndex, length, 'next');
202197
renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
203198
},
204199
previous() {
205200
verifiedWidget.moveFocus(focusedItem, 'previous');
206-
if (!!responseIndex) {
207-
const notificationNumber = responseIndex + 1;
208-
if (!!notificationNumber && !!length && notificationNumber - 1 > 0) {
209-
alert(`Focused ${notificationNumber - 1} of ${length}`);
210-
}
211-
}
201+
alertFocusChange(responseIndex, length, 'previous');
212202
renderAccessibleView(accessibleViewService, widgetService, codeEditorService);
213203
},
214204
options: { ariaLabel: nls.localize('chatAccessibleView', "Chat Accessible View"), type: AccessibleViewType.View }

0 commit comments

Comments
 (0)