Change:
[x] Indicate when a document has commentable ranges Aria status when a document is opened [x] Add keyboard shortcut for adding a comment [x] Provide commands to go to next and previous commentable range [x] Add an accessible help menu to the comment widget Esc dismisses widget Lists go to next/previous commentable range commands + keyboard shortcuts Lists command and keyboard shortcut to add a comment Lists keyboard shortcut to execute the comment primary action and what the primary action is [x] The Comments view should respect the enter/space = reveal+focus/reveal [x] Make the comment widget toolbar always visible when in screen reader mode
Related to
is the last part of this, and it's almost done!
Mr.KITSANAPAN MEEKEAW

Discussion:
} } <ins> private areRangesIntersectingOrTouchingByLine(a: Range, b: Range) { // Check if `a` is before `b` if (a.endLineNumber < b.startLineNumber) { return false; } // Check if `b` is before `a` if (b.endLineNumber < a.startLineNumber) { return false; } // These ranges must intersect return true; } </ins> public getMatchedCommentAction(commentRange: Range | undefined): CommentRangeAction[] { if (commentRange === undefined) { const foundInfos = this._infos?.filter(info => info.commentingRanges.fileComments);

const foundHoverActions = new Map<string, { range: Range; action: CommentRangeAction }>(); for (const decoration of this.commentingRangeDecorations) { const range = decoration.getActiveRange(); <del> if (range && ((range.startLineNumber <= commentRange.startLineNumber) || (commentRange.endLineNumber <= range.endLineNumber))) { </del> <ins> if (range && this.areRangesIntersectingOrTouchingByLine(range, commentRange)) { </ins> // We can have several commenting ranges that match from the same owner because of how // the line hover and selection decoration is done. // The ranges must be merged so that we can see if the new commentRange fits within them.

const newCommentInfos = this._commentingRangeDecorator.getMatchedCommentAction(range); if (!newCommentInfos.length || !this.editor?.hasModel()) { this._addInProgress = false; <ins> if (!newCommentInfos.length) { throw new Error('There are no commenting ranges at the current position.'); } </ins> return Promise.resolve(); }

import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ActiveCursorHasCommentingRange, CommentController, ID } from 'vs/workbench/contrib/comments/browser/commentsController'; import { IRange, Range } from 'vs/editor/common/core/range'; <ins> import { INotificationService } from 'vs/platform/notification/common/notification'; </ins> export class NextCommentThreadAction extends EditorAction { constructor() {

}); const ADD_COMMENT_COMMAND = 'workbench.action.addComment'; <del> CommandsRegistry.registerCommand({ </del> <ins> KeybindingsRegistry.registerCommandAndKeybindingRule({ </ins> id: ADD_COMMENT_COMMAND, <del> handler: (accessor, args?: { range: IRange; fileComment: boolean }) => { </del> <ins> handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { </ins> const activeEditor = getActiveEditor(accessor); if (!activeEditor) { return Promise.resolve();

const position = args?.range ? new Range(args.range.startLineNumber, args.range.startLineNumber, args.range.endLineNumber, args.range.endColumn) : (args?.fileComment ? undefined : activeEditor.getSelection()); <del> return controller.addOrToggleCommentAtLine(position, undefined); } </del> <ins> const notificationService = accessor.get(INotificationService); try { await controller.addOrToggleCommentAtLine(position, undefined); } catch (e) { notificationService.error(nls.localize('comments.addCommand.error', "The cursor must be within a commenting range to add a comment")); // TODO: Once we have commands to go to next commenting range they should be included as buttons in the error. } }, weight: KeybindingWeight.EditorContrib, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyC, </ins> }); MenuRegistry.appendMenuItem(MenuId.CommandPalette, {