Skip to content

Conversation

@dineshc-msft
Copy link
Contributor

Added actions for navigating across files in multi-file diff editor and added aria-label for information on file modified/added/deleted. Addresses issue: #264299

Below gif shows the changes in action.

multiDiffAcc

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds navigation commands to the multi-diff editor, allowing users to navigate between files using "Go to Next File" and "Go to Previous File" actions. It also improves accessibility by adding ARIA labels and keyboard navigation support.

Key changes:

  • Added goToNextFile() and goToPreviousFile() navigation methods throughout the multi-diff editor architecture
  • Introduced accessibility improvements with ARIA labels and keyboard focus management for file containers
  • Registered new navigation actions in the command palette

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.ts Added public navigation methods goToNextFile() and goToPreviousFile() to the MultiDiffEditor class
src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditor.contribution.ts Imported and registered the new GoToNextFileAction and GoToPreviousFileAction commands
src/vs/workbench/contrib/multiDiffEditor/browser/actions.ts Defined new action classes for navigating to next/previous files with command palette integration
src/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl.ts Implemented navigation logic with scrolling and focus management, added ARIA label to main editor container
src/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidget.ts Added delegation methods to call the widget implementation's navigation functions
src/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.ts Added localize import, ARIA labels for individual file containers, and getContainerElement() method for focus management

Comment on lines +276 to +278
fileAriaLabel = localize('modifiedFileHeader', '{0} file {1}', status, modifiedFileName);
} else {
fileAriaLabel = localize('modifiedFileHeader', '{0} file {1}', status, originalFileName);
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The localization key 'modifiedFileHeader' is used for both 'Added' and 'Modified'/'Deleted' status messages (lines 276 and 278). Consider using a more generic key name like 'fileHeader' since it's not exclusively for modified files, or use distinct keys for each status type to allow for more context-specific translations.

Suggested change
fileAriaLabel = localize('modifiedFileHeader', '{0} file {1}', status, modifiedFileName);
} else {
fileAriaLabel = localize('modifiedFileHeader', '{0} file {1}', status, originalFileName);
fileAriaLabel = localize('addedFileHeader', 'Added file {0}', modifiedFileName);
} else if (isDeleted) {
fileAriaLabel = localize('deletedFileHeader', 'Deleted file {0}', originalFileName);
} else {
fileAriaLabel = localize('modifiedFileHeader', 'Modified file {0}', originalFileName);

Copilot uses AI. Check for mistakes.
const currentIndex = activeItem ? items.indexOf(activeItem) : -1;
const nextIndex = Math.min(currentIndex + 1, items.length - 1);

if (nextIndex !== currentIndex && nextIndex >= 0) {
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check nextIndex >= 0 on line 363 is redundant. Since currentIndex can be at minimum -1, and nextIndex = currentIndex + 1, the minimum value of nextIndex is 0. The condition nextIndex !== currentIndex is sufficient to ensure we're not already at the last item.

Suggested change
if (nextIndex !== currentIndex && nextIndex >= 0) {
if (nextIndex !== currentIndex) {

Copilot uses AI. Check for mistakes.
const currentIndex = activeItem ? items.indexOf(activeItem) : -1;
const prevIndex = Math.max(currentIndex - 1, 0);

if (prevIndex !== currentIndex && prevIndex >= 0) {
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check prevIndex >= 0 on line 382 is redundant. Since prevIndex = Math.max(currentIndex - 1, 0), it's guaranteed to be at least 0. The condition prevIndex !== currentIndex is sufficient to ensure we're not already at the first item.

Suggested change
if (prevIndex !== currentIndex && prevIndex >= 0) {
if (prevIndex !== currentIndex) {

Copilot uses AI. Check for mistakes.
this._elements.status.innerText = flag;

// Set aria-label for the individual file container
const originalFileName = data.viewModel.originalUri?.path.split('/').pop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use basename

}
}

private scrollToItem(index: number): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we don't want to use MultiDiffEditorWidgetImpl#reveal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants