From 778f5ace1ef0fef81aba0a55f3f50aaeed7dde9d Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 18 Sep 2023 17:25:53 -0700 Subject: [PATCH 01/15] add comment widget help dialog --- .../browser/accessibility.contribution.ts | 2 + .../browser/accessibilityConfiguration.ts | 7 ++- .../comments/browser/commentThreadWidget.ts | 29 +++++++++-- .../browser/commentThreadZoneWidget.ts | 2 +- .../comments/browser/comments.contribution.ts | 49 +++++++++++++++++++ .../comments/common/commentContextKeys.ts | 5 ++ 6 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts b/src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts index de7ddcd7c0c73..efc4a052f460a 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts @@ -12,12 +12,14 @@ import { IAccessibleViewService, AccessibleViewService } from 'vs/workbench/cont import { UnfocusedViewDimmingContribution } from 'vs/workbench/contrib/accessibility/browser/unfocusedViewDimmingContribution'; import { EditorAccessibilityHelpContribution, HoverAccessibleViewContribution, InlineCompletionsAccessibleViewContribution, NotificationAccessibleViewContribution } from 'vs/workbench/contrib/accessibility/browser/accessibilityContributions'; import { AccessibilityStatus } from 'vs/workbench/contrib/accessibility/browser/accessibilityStatus'; +import { CommentsAccessibilityHelpContribution } from 'vs/workbench/contrib/comments/browser/comments.contribution'; registerAccessibilityConfiguration(); registerSingleton(IAccessibleViewService, AccessibleViewService, InstantiationType.Delayed); const workbenchRegistry = Registry.as(WorkbenchExtensions.Workbench); workbenchRegistry.registerWorkbenchContribution(EditorAccessibilityHelpContribution, LifecyclePhase.Eventually); +workbenchRegistry.registerWorkbenchContribution(CommentsAccessibilityHelpContribution, LifecyclePhase.Eventually); workbenchRegistry.registerWorkbenchContribution(UnfocusedViewDimmingContribution, LifecyclePhase.Restored); const workbenchContributionsRegistry = Registry.as(WorkbenchExtensions.Workbench); diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts index 6a6df6719ef96..aab2724f03ef7 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts @@ -43,7 +43,8 @@ export const enum AccessibilityVerbositySettingId { Editor = 'accessibility.verbosity.editor', Hover = 'accessibility.verbosity.hover', Notification = 'accessibility.verbosity.notification', - EmptyEditorHint = 'accessibility.verbosity.emptyEditorHint' + EmptyEditorHint = 'accessibility.verbosity.emptyEditorHint', + Comments = 'accessibility.verbosity.comments' } export const enum AccessibleViewProviderId { @@ -110,6 +111,10 @@ const configuration: IConfigurationNode = { [AccessibilityVerbositySettingId.EmptyEditorHint]: { description: localize('verbosity.emptyEditorHint', 'Provide information about relevant actions in an empty text editor.'), ...baseProperty + }, + [AccessibilityVerbositySettingId.Comments]: { + description: localize('verbosity.comments', 'Provide information about relevant actions the comment widget or in a file which contains comments.'), + ...baseProperty } } }; diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index aff152a1a9cd6..171730f744756 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -31,6 +31,10 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { COMMENTS_SECTION, ICommentsConfiguration } from 'vs/workbench/contrib/comments/common/commentsConfiguration'; +import { localize } from 'vs/nls'; +import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { AccessibilityCommandId } from 'vs/workbench/contrib/accessibility/common/accessibilityCommands'; export const COMMENTEDITOR_DECORATION_KEY = 'commenteditordecoration'; @@ -45,6 +49,7 @@ export class CommentThreadWidget extends private _threadIsEmpty: IContextKey; private _styleElement: HTMLStyleElement; private _commentThreadContextValue: IContextKey; + private _focusedContextKey: IContextKey; private _onDidResize = new Emitter(); onDidResize = this._onDidResize.event; @@ -53,7 +58,6 @@ export class CommentThreadWidget extends get commentThread() { return this._commentThread; } - constructor( readonly container: HTMLElement, private _owner: string, @@ -71,12 +75,14 @@ export class CommentThreadWidget extends }, @ICommentService private commentService: ICommentService, @IContextMenuService contextMenuService: IContextMenuService, - @IConfigurationService private configurationService: IConfigurationService + @IConfigurationService private configurationService: IConfigurationService, + @IKeybindingService private _keybindingService: IKeybindingService ) { super(); this._threadIsEmpty = CommentContextKeys.commentThreadIsEmpty.bindTo(this._contextKeyService); this._threadIsEmpty.set(!_commentThread.comments || !_commentThread.comments.length); + this._focusedContextKey = CommentContextKeys.commentFocused.bindTo(this._contextKeyService); this._commentMenus = this.commentService.getCommentMenus(this._owner); @@ -111,6 +117,8 @@ export class CommentThreadWidget extends } } })); + this._register(tracker.onDidFocus(() => this._focusedContextKey.set(true))); + this._register(tracker.onDidBlur(() => this._focusedContextKey.reset())); this._body = this._scopedInstantiationService.createInstance( CommentThreadBody, @@ -124,7 +132,7 @@ export class CommentThreadWidget extends this ) as unknown as CommentThreadBody; this._register(this._body); - + this._setAriaLabel(); this._styleElement = dom.createStyleSheet(this.container); @@ -141,6 +149,21 @@ export class CommentThreadWidget extends this.currentThreadListeners(); } + private _setAriaLabel(): void { + let ariaLabel = localize('commentLabel', "Comment"); + let keybinding: string | undefined; + const verbose = this.configurationService.getValue(AccessibilityVerbositySettingId.Comments); + if (verbose) { + keybinding = this._keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp, this._contextKeyService)?.getLabel() ?? undefined; + } + if (keybinding) { + ariaLabel = localize('commentLabelWithKeybinding', "{0}, use ({1}) for accessibility help", ariaLabel, keybinding); + } else { + ariaLabel = localize('commentLabelWithKeybindingNoKeybinding', "{0}, run the command Open Accessibility Help which is currently not triggerable via keybinding.", ariaLabel); + } + this._body.container.ariaLabel = ariaLabel; + } + private updateCurrentThread(hasMouse: boolean, hasFocus: boolean) { if (hasMouse || hasFocus) { this.commentService.setCurrentCommentThread(this.commentThread); diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts index b9da89e59853d..5a5fa847ae01c 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts @@ -153,7 +153,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget } })); this._applyTheme(this.themeService.getColorTheme()); - } public get onDidClose(): Event { @@ -217,6 +216,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget protected _fillContainer(container: HTMLElement): void { this.setCssClass('review-widget'); + this._commentThreadWidget = this._scopedInstantiationService.createInstance( CommentThreadWidget, container, diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index 63400eb834cb7..b3b51392b3b16 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -9,6 +9,17 @@ import { Registry } from 'vs/platform/registry/common/platform'; import 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; import { ICommentService, CommentService } from 'vs/workbench/contrib/comments/browser/commentService'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; +import { ctxCommentEditorFocused } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; +// import * as strings from 'vs/base/common/strings'; +import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; +import { AccessibleViewType, IAccessibleContentProvider, IAccessibleViewOptions, IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView'; +import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { Disposable } from 'vs/base/common/lifecycle'; +import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; + Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ id: 'comments', @@ -54,3 +65,41 @@ Registry.as(ConfigurationExtensions.Configuration).regis }); registerSingleton(ICommentService, CommentService, InstantiationType.Delayed); + + +export class CommentsAccessibilityHelpContribution extends Disposable { + static ID: 'commentsAccessibilityHelpContribution'; + constructor() { + super(); + this._register(AccessibilityHelpAction.addImplementation(110, 'comments', accessor => { + const instantiationService = accessor.get(IInstantiationService); + const accessibleViewService = accessor.get(IAccessibleViewService); + accessibleViewService.show(instantiationService.createInstance(CommentsAccessibilityHelpProvider)); + return true; + }, ContextKeyExpr.or(ctxCommentEditorFocused, CommentContextKeys.commentFocused))); + } +} +export class CommentsAccessibilityHelpProvider implements IAccessibleContentProvider { + verbositySettingKey: AccessibilityVerbositySettingId = AccessibilityVerbositySettingId.Comments; + options: IAccessibleViewOptions = { type: AccessibleViewType.Help }; + private _element: HTMLElement | undefined; + constructor( + // @IKeybindingService private readonly _keybindingService: IKeybindingService + ) { + + } + // private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string { + // const kb = this._keybindingService.lookupKeybinding(commandId); + // if (kb) { + // return strings.format(msg, kb.getAriaLabel()); + // } + // return strings.format(noKbMsg, commandId); + // } + provideContent(): string { + this._element = document.activeElement as HTMLElement; + return 'Comment help info'; + } + onClose(): void { + this._element?.focus(); + } +} diff --git a/src/vs/workbench/contrib/comments/common/commentContextKeys.ts b/src/vs/workbench/contrib/comments/common/commentContextKeys.ts index c4b32556b316c..cc8ed727f376d 100644 --- a/src/vs/workbench/contrib/comments/common/commentContextKeys.ts +++ b/src/vs/workbench/contrib/comments/common/commentContextKeys.ts @@ -28,4 +28,9 @@ export namespace CommentContextKeys { * The comment controller id associated with a comment thread. */ export const commentControllerContext = new RawContextKey('commentController', undefined, { type: 'string', description: nls.localize('commentController', "The comment controller id associated with a comment thread") }); + + /** + * The comment widget is focused. + */ + export const commentFocused = new RawContextKey('commentFocused', false, { type: 'boolean', description: nls.localize('commentFocused', "Set when the comment is focused") }); } From 6d286af72b8a213276b924b137e72ea10602b627 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Mon, 18 Sep 2023 17:27:33 -0700 Subject: [PATCH 02/15] Update src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts --- .../contrib/accessibility/browser/accessibilityConfiguration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts index aab2724f03ef7..1fa6cbef9863e 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts @@ -113,7 +113,7 @@ const configuration: IConfigurationNode = { ...baseProperty }, [AccessibilityVerbositySettingId.Comments]: { - description: localize('verbosity.comments', 'Provide information about relevant actions the comment widget or in a file which contains 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 } } From 16eda558e930b4e4b815ebba49e9d27e9fa451be Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Mon, 18 Sep 2023 17:28:18 -0700 Subject: [PATCH 03/15] Apply suggestions from code review --- .../contrib/comments/browser/commentThreadZoneWidget.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts index 5a5fa847ae01c..b9da89e59853d 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts @@ -153,6 +153,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget } })); this._applyTheme(this.themeService.getColorTheme()); + } public get onDidClose(): Event { @@ -216,7 +217,6 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget protected _fillContainer(container: HTMLElement): void { this.setCssClass('review-widget'); - this._commentThreadWidget = this._scopedInstantiationService.createInstance( CommentThreadWidget, container, From 55c24c5c028e21826db53a628d4d02823903409d Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 19 Sep 2023 10:56:47 -0700 Subject: [PATCH 04/15] add content --- .../comments/browser/comments.contribution.ts | 40 ++++++++++++++----- .../comments/browser/commentsController.ts | 18 ++++++++- .../browser/commentsEditorContribution.ts | 8 ++-- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index b3b51392b3b16..81b4ee6884479 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -6,11 +6,10 @@ import * as nls from 'vs/nls'; import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { Registry } from 'vs/platform/registry/common/platform'; -import 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; import { ICommentService, CommentService } from 'vs/workbench/contrib/comments/browser/commentService'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; import { ctxCommentEditorFocused } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; -// import * as strings from 'vs/base/common/strings'; +import * as strings from 'vs/base/common/strings'; import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; import { AccessibleViewType, IAccessibleContentProvider, IAccessibleViewOptions, IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView'; import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions'; @@ -19,6 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; +import { ADD_COMMENT_COMMAND, NextCommentThreadAction, PreviousCommentThreadAction } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ @@ -67,6 +67,18 @@ Registry.as(ConfigurationExtensions.Configuration).regis registerSingleton(ICommentService, CommentService, InstantiationType.Delayed); +namespace CommentAccessibilityHelpNLS { + export const escape = nls.localize('escape', "Dismiss the comment widget via Escape."); + export const next = nls.localize('next', "Navigate to the next comment thread via ({0})."); + export const nextNoKb = nls.localize('nextNoKb', "Navigate to the next comment thread via ({0})."); + export const previous = nls.localize('previous', "Navigate to the previous comment thread via ({0})."); + export const previousNoKb = nls.localize('previousNoKb', "Navigate to the previous comment thread via ({0})."); + export const addComment = nls.localize('addComment', "Add a comment via ({0})."); + export const addCommentNoKb = nls.localize('addCommentNoKb', "Add a comment via ({0})."); + export const submitComment = nls.localize('submitComment', "Submit the comment via({0})."); + export const submitCommentNoKb = nls.localize('submitCommentNoKb', "Submit the comment via ({0})."); +} + export class CommentsAccessibilityHelpContribution extends Disposable { static ID: 'commentsAccessibilityHelpContribution'; constructor() { @@ -84,20 +96,26 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv options: IAccessibleViewOptions = { type: AccessibleViewType.Help }; private _element: HTMLElement | undefined; constructor( - // @IKeybindingService private readonly _keybindingService: IKeybindingService + @IKeybindingService private readonly _keybindingService: IKeybindingService ) { } - // private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string { - // const kb = this._keybindingService.lookupKeybinding(commandId); - // if (kb) { - // return strings.format(msg, kb.getAriaLabel()); - // } - // return strings.format(noKbMsg, commandId); - // } + private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string { + const kb = this._keybindingService.lookupKeybinding(commandId); + if (kb) { + return strings.format(msg, kb.getAriaLabel()); + } + return strings.format(noKbMsg, commandId); + } provideContent(): string { this._element = document.activeElement as HTMLElement; - return 'Comment help info'; + const content: string[] = []; + content.push(CommentAccessibilityHelpNLS.escape); + content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); + content.push(this._descriptionForCommand(NextCommentThreadAction.ID, CommentAccessibilityHelpNLS.next, CommentAccessibilityHelpNLS.nextNoKb)); + content.push(this._descriptionForCommand(PreviousCommentThreadAction.ID, CommentAccessibilityHelpNLS.previous, CommentAccessibilityHelpNLS.previousNoKb)); + content.push(this._descriptionForCommand('workbench.action.submitComment', CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); + return content.join('\n\n'); } onClose(): void { this._element?.focus(); diff --git a/src/vs/workbench/contrib/comments/browser/commentsController.ts b/src/vs/workbench/contrib/comments/browser/commentsController.ts index 23eea52044075..5e42b720516db 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsController.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsController.ts @@ -40,6 +40,9 @@ import { ICursorSelectionChangedEvent } from 'vs/editor/common/cursorEvents'; import { CommentsPanel } from 'vs/workbench/contrib/comments/browser/commentsView'; import { status } from 'vs/base/browser/ui/aria/aria'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; +import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; +import { AccessibilityCommandId } from 'vs/workbench/contrib/accessibility/common/accessibilityCommands'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; export const ID = 'editor.contrib.review'; @@ -380,7 +383,8 @@ export class CommentController implements IEditorContribution { @IViewsService private readonly viewsService: IViewsService, @IConfigurationService private readonly configurationService: IConfigurationService, @IContextKeyService contextKeyService: IContextKeyService, - @IEditorService private readonly editorService: IEditorService + @IEditorService private readonly editorService: IEditorService, + @IKeybindingService private readonly keybindingService: IKeybindingService ) { this._commentInfos = []; this._commentWidgets = []; @@ -848,7 +852,17 @@ export class CommentController implements IEditorContribution { if (this._commentInfos.some(commentInfo => commentInfo.commentingRanges.ranges.length > 0 || commentInfo.commentingRanges.fileComments)) { this._hasRespondedToEditorChange = true; this._activeEditorHasCommentingRange.set(true); - status(nls.localize('hasCommentRanges', "Editor has commenting ranges.")); + const verbose = this.configurationService.getValue(AccessibilityVerbositySettingId.Comments); + if (verbose) { + const keybinding = this.keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getAriaLabel(); + if (keybinding) { + status(nls.localize('hasCommentRangesKb', "Editor has commenting ranges, run the command Open Accessibility Help ({0}), for more information.", keybinding)); + } else { + status(nls.localize('hasCommentRangesNoKb', "Editor has commenting ranges, run the command Open Accessibility Help, which is currently not triggerable via keybinding, for more information.")); + } + } else { + status(nls.localize('hasCommentRanges', "Editor has commenting ranges.")); + } } else { this._activeEditorHasCommentingRange.set(false); } diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 6384fe1e2cd0f..a7c16d3b2791c 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -23,9 +23,10 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; export class NextCommentThreadAction extends EditorAction { + static ID: string = 'editor.action.nextCommentThread'; constructor() { super({ - id: 'editor.action.nextCommentThreadAction', + id: ID, label: nls.localize('nextCommentThreadAction', "Go to Next Comment Thread"), alias: 'Go to Next Comment Thread', precondition: undefined, @@ -44,9 +45,10 @@ export class NextCommentThreadAction extends EditorAction { } export class PreviousCommentThreadAction extends EditorAction { + static ID: string = 'editor.action.previousCommentThread'; constructor() { super({ - id: 'editor.action.previousCommentThreadAction', + id: ID, label: nls.localize('previousCommentThreadAction', "Go to Previous Comment Thread"), alias: 'Go to Previous Comment Thread', precondition: undefined, @@ -132,7 +134,7 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { when: CommentContextKeys.WorkspaceHasCommenting }); -const ADD_COMMENT_COMMAND = 'workbench.action.addComment'; +export const ADD_COMMENT_COMMAND = 'workbench.action.addComment'; KeybindingsRegistry.registerCommandAndKeybindingRule({ id: ADD_COMMENT_COMMAND, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { From e49c56aab86fc41bae923b90962cc4cdc2de622a Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 19 Sep 2023 12:18:38 -0700 Subject: [PATCH 05/15] add more content --- .../browser/accessibilityConfiguration.ts | 3 ++- .../comments/browser/comments.contribution.ts | 22 +++++++++---------- .../browser/commentsEditorContribution.ts | 16 +++++++++----- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts index 1fa6cbef9863e..2b9fecde5ce7d 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts @@ -58,7 +58,8 @@ export const enum AccessibleViewProviderId { Editor = 'editor', Hover = 'hover', Notification = 'notification', - EmptyEditorHint = 'emptyEditorHint' + EmptyEditorHint = 'emptyEditorHint', + Comments = 'comments' } const baseProperty: object = { diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index 81b4ee6884479..7a56f0e89ab61 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -18,7 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import { ADD_COMMENT_COMMAND, NextCommentThreadAction, PreviousCommentThreadAction } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { ADD_COMMENT_COMMAND, NextCommentingRangeAction, PreviousCommentingRangeAction, SUBMIT_COMMENT_COMMAND_ID } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ @@ -69,14 +69,14 @@ registerSingleton(ICommentService, CommentService, InstantiationType.Delayed); namespace CommentAccessibilityHelpNLS { export const escape = nls.localize('escape', "Dismiss the comment widget via Escape."); - export const next = nls.localize('next', "Navigate to the next comment thread via ({0})."); - export const nextNoKb = nls.localize('nextNoKb', "Navigate to the next comment thread via ({0})."); - export const previous = nls.localize('previous', "Navigate to the previous comment thread via ({0})."); - export const previousNoKb = nls.localize('previousNoKb', "Navigate to the previous comment thread via ({0})."); + export const next = nls.localize('next', "Navigate to the next commenting range via ({0})."); + export const nextNoKb = nls.localize('nextNoKb', "Run the command: Go to Next Commenting Range, which is currently not triggerable via keybinding."); + export const previous = nls.localize('previous', "Navigate to the previous comment range via ({0})."); + export const previousNoKb = nls.localize('previousNoKb', "Run the command: Go to Previous Commenting Range, which is currently not triggerable via keybinding."); export const addComment = nls.localize('addComment', "Add a comment via ({0})."); - export const addCommentNoKb = nls.localize('addCommentNoKb', "Add a comment via ({0})."); - export const submitComment = nls.localize('submitComment', "Submit the comment via({0})."); - export const submitCommentNoKb = nls.localize('submitCommentNoKb', "Submit the comment via ({0})."); + export const addCommentNoKb = nls.localize('addCommentNoKb', "Add a comment via the command: Add Comment on Current Selection, which is currently not triggerable via keybinding."); + export const submitComment = nls.localize('submitComment', "Submit the comment via ({0})."); + export const submitCommentNoKb = nls.localize('submitCommentNoKb', "Submit the comment by navigating with tab to the button, as it's currently not triggerable via keybinding."); } export class CommentsAccessibilityHelpContribution extends Disposable { @@ -112,9 +112,9 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv const content: string[] = []; content.push(CommentAccessibilityHelpNLS.escape); content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(NextCommentThreadAction.ID, CommentAccessibilityHelpNLS.next, CommentAccessibilityHelpNLS.nextNoKb)); - content.push(this._descriptionForCommand(PreviousCommentThreadAction.ID, CommentAccessibilityHelpNLS.previous, CommentAccessibilityHelpNLS.previousNoKb)); - content.push(this._descriptionForCommand('workbench.action.submitComment', CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); + content.push(this._descriptionForCommand(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.next, CommentAccessibilityHelpNLS.nextNoKb)); + content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previous, CommentAccessibilityHelpNLS.previousNoKb)); + content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); return content.join('\n\n'); } onClose(): void { diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index a7c16d3b2791c..4755e3c608945 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -21,6 +21,9 @@ import { CommentController, ID } from 'vs/workbench/contrib/comments/browser/com import { IRange, Range } from 'vs/editor/common/core/range'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; +import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility'; +import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { accessibilityHelpIsShown, accessibleViewCurrentProviderId, AccessibleViewProviderId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; export class NextCommentThreadAction extends EditorAction { static ID: string = 'editor.action.nextCommentThread'; @@ -71,14 +74,15 @@ registerEditorAction(NextCommentThreadAction); registerEditorAction(PreviousCommentThreadAction); export class NextCommentingRangeAction extends EditorAction { + static ID: string = 'editor.action.goToNextCommentingRange'; constructor() { super({ - id: 'editor.action.goToNextCommentingRange', + id: ID, label: nls.localize('goToNextCommentingRange', "Go to Next Commenting Range"), alias: 'Go to Next Commenting Range', precondition: CommentContextKeys.WorkspaceHasCommenting, kbOpts: { - kbExpr: EditorContextKeys.focus, + kbExpr: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ContextKeyExpr.and(accessibilityHelpIsShown, accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Comments)))), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.DownArrow), weight: KeybindingWeight.EditorContrib } @@ -92,14 +96,15 @@ export class NextCommentingRangeAction extends EditorAction { } export class PreviousCommentingRangeAction extends EditorAction { + static ID: 'editor.action.goToPreviousCommentingRange'; constructor() { super({ - id: 'editor.action.goToPreviousCommentingRange', + id: ID, label: nls.localize('goToPreviousCommentingRange', "Go to Previous Commenting Range"), alias: 'Go to Next Commenting Range', precondition: CommentContextKeys.WorkspaceHasCommenting, kbOpts: { - kbExpr: EditorContextKeys.focus, + kbExpr: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ContextKeyExpr.and(accessibilityHelpIsShown, accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Comments)))), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.UpArrow), weight: KeybindingWeight.EditorContrib } @@ -221,8 +226,9 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { when: CommentContextKeys.WorkspaceHasCommenting }); +export const SUBMIT_COMMENT_COMMAND_ID = 'workbench.action.submitComment'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: 'workbench.action.submitComment', + id: SUBMIT_COMMENT_COMMAND_ID, weight: KeybindingWeight.EditorContrib, primary: KeyMod.CtrlCmd | KeyCode.Enter, when: ctxCommentEditorFocused, From e252fd620b4b707eb3430b4009061eb6556e0e53 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 19 Sep 2023 13:51:25 -0700 Subject: [PATCH 06/15] add to editor help menu --- .../browser/accessibilityContributions.ts | 14 ++++++++++++-- .../comments/browser/commentThreadWidget.ts | 6 +++++- .../comments/browser/comments.contribution.ts | 18 +++++++++++------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts index 11bf6795196d9..74e5dcdd655d4 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts @@ -37,7 +37,10 @@ import { ThemeIcon } from 'vs/base/common/themables'; import { Codicon } from 'vs/base/common/codicons'; import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController'; import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys'; -import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; +import { ADD_COMMENT_COMMAND, NextCommentingRangeAction, PreviousCommentingRangeAction } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { CommentAccessibilityHelpNLS } from 'vs/workbench/contrib/comments/browser/comments.contribution'; export class EditorAccessibilityHelpContribution extends Disposable { static ID: 'editorAccessibilityHelpContribution'; @@ -66,7 +69,8 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider { verbositySettingKey = AccessibilityVerbositySettingId.Editor; constructor( private readonly _editor: ICodeEditor, - @IKeybindingService private readonly _keybindingService: IKeybindingService + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService ) { } @@ -96,6 +100,12 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider { } } + if (this._contextKeyService.getContextKeyValue(CommentContextKeys.activeEditorHasCommentingRange.key)) { + content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); + content.push(this._descriptionForCommand(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + } + if (options.get(EditorOption.stickyScroll).enabled) { content.push(this._descriptionForCommand('editor.action.focusStickyScroll', AccessibilityHelpNLS.stickScrollKb, AccessibilityHelpNLS.stickScrollNoKb)); } diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 171730f744756..bfae89f49af9c 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -119,7 +119,11 @@ export class CommentThreadWidget extends })); this._register(tracker.onDidFocus(() => this._focusedContextKey.set(true))); this._register(tracker.onDidBlur(() => this._focusedContextKey.reset())); - + this._register(this.configurationService.onDidChangeConfiguration(e => { + if (e.affectsConfiguration(AccessibilityVerbositySettingId.Comments)) { + this._setAriaLabel(); + } + })); this._body = this._scopedInstantiationService.createInstance( CommentThreadBody, this._owner, diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index 7a56f0e89ab61..96f7bd91ae9d0 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -67,12 +67,16 @@ Registry.as(ConfigurationExtensions.Configuration).regis registerSingleton(ICommentService, CommentService, InstantiationType.Delayed); -namespace CommentAccessibilityHelpNLS { +export namespace CommentAccessibilityHelpNLS { export const escape = nls.localize('escape', "Dismiss the comment widget via Escape."); - export const next = nls.localize('next', "Navigate to the next commenting range via ({0})."); - export const nextNoKb = nls.localize('nextNoKb', "Run the command: Go to Next Commenting Range, which is currently not triggerable via keybinding."); - export const previous = nls.localize('previous', "Navigate to the previous comment range via ({0})."); - export const previousNoKb = nls.localize('previousNoKb', "Run the command: Go to Previous Commenting Range, which is currently not triggerable via keybinding."); + export const nextRange = nls.localize('next', "Navigate to the next commenting range via ({0})."); + export const nextRangeNoKb = nls.localize('nextNoKb', "Run the command: Go to Next Commenting Range, which is currently not triggerable via keybinding."); + export const previousRange = nls.localize('previous', "Navigate to the previous comment range via ({0})."); + export const previousRangeNoKb = nls.localize('previousNoKb', "Run the command: Go to Previous Commenting Range, which is currently not triggerable via keybinding."); + export const nextCommentThreadKb = nls.localize('nextCommentThreadKb', "Navigate to the next comment thread via ({0})."); + export const nextCommentThreadNoKb = nls.localize('nextCommentThreadNoKb', "Run the command: Go to Next Comment Thread, which is currently not triggerable via keybinding."); + export const previousCommentThreadKb = nls.localize('previousCommentThreadKb', "Navigate to the previous comment thread via ({0})."); + export const previousCommentThreadNoKb = nls.localize('previousCommentThreadNoKb', "Run the command: Go to Previous Comment Thread, which is currently not triggerable via keybinding."); export const addComment = nls.localize('addComment', "Add a comment via ({0})."); export const addCommentNoKb = nls.localize('addCommentNoKb', "Add a comment via the command: Add Comment on Current Selection, which is currently not triggerable via keybinding."); export const submitComment = nls.localize('submitComment', "Submit the comment via ({0})."); @@ -112,8 +116,8 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv const content: string[] = []; content.push(CommentAccessibilityHelpNLS.escape); content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.next, CommentAccessibilityHelpNLS.nextNoKb)); - content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previous, CommentAccessibilityHelpNLS.previousNoKb)); + content.push(this._descriptionForCommand(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); return content.join('\n\n'); } From 6c7fb4d5b0199277c152ef6bff6be1e7380f67d5 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 19 Sep 2023 14:45:18 -0700 Subject: [PATCH 07/15] allow commands to have discoverable keybindings --- .../browser/accessibilityContributions.ts | 8 +- .../comments/browser/comments.contribution.ts | 6 +- .../browser/commentsEditorContribution.ts | 164 ++++++++---------- 3 files changed, 85 insertions(+), 93 deletions(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts index 74e5dcdd655d4..8a0761f9c74ea 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts @@ -39,7 +39,7 @@ import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys'; import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import { ADD_COMMENT_COMMAND, NextCommentingRangeAction, PreviousCommentingRangeAction } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { ADD_COMMENT_COMMAND, NEXT_COMMENT_RANGE_COMMAND_ID, NEXT_COMMENT_THREAD_COMMAND_ID, PREVIOUS_COMMENT_RANGE_COMMAND_ID, PREVIOUS_COMMENT_THREAD_COMMAND_ID } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; import { CommentAccessibilityHelpNLS } from 'vs/workbench/contrib/comments/browser/comments.contribution'; export class EditorAccessibilityHelpContribution extends Disposable { @@ -102,8 +102,10 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider { if (this._contextKeyService.getContextKeyValue(CommentContextKeys.activeEditorHasCommentingRange.key)) { content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); - content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + content.push(this._descriptionForCommand(NEXT_COMMENT_THREAD_COMMAND_ID, CommentAccessibilityHelpNLS.nextCommentThreadKb, CommentAccessibilityHelpNLS.nextCommentThreadNoKb)); + content.push(this._descriptionForCommand(PREVIOUS_COMMENT_THREAD_COMMAND_ID, CommentAccessibilityHelpNLS.previousCommentThreadKb, CommentAccessibilityHelpNLS.previousCommentThreadNoKb)); + content.push(this._descriptionForCommand(NEXT_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(PREVIOUS_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); } if (options.get(EditorOption.stickyScroll).enabled) { diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index 96f7bd91ae9d0..4c3c94875bb95 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -18,7 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import { ADD_COMMENT_COMMAND, NextCommentingRangeAction, PreviousCommentingRangeAction, SUBMIT_COMMENT_COMMAND_ID } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { ADD_COMMENT_COMMAND, NEXT_COMMENT_RANGE_COMMAND_ID, PREVIOUS_COMMENT_RANGE_COMMAND_ID, SUBMIT_COMMENT_COMMAND_ID } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ @@ -116,8 +116,8 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv const content: string[] = []; content.push(CommentAccessibilityHelpNLS.escape); content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); - content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + content.push(this._descriptionForCommand(NEXT_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(PREVIOUS_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); return content.join('\n\n'); } diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 4755e3c608945..30035118a402f 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -5,8 +5,8 @@ import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import 'vs/css!./media/review'; -import { IActiveCodeEditor, ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; -import { EditorAction, EditorContributionInstantiation, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; +import { IActiveCodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; +import { EditorContributionInstantiation, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import * as nls from 'vs/nls'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; @@ -25,100 +25,90 @@ import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/co import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { accessibilityHelpIsShown, accessibleViewCurrentProviderId, AccessibleViewProviderId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; -export class NextCommentThreadAction extends EditorAction { - static ID: string = 'editor.action.nextCommentThread'; - constructor() { - super({ - id: ID, - label: nls.localize('nextCommentThreadAction', "Go to Next Comment Thread"), - alias: 'Go to Next Comment Thread', - precondition: undefined, - kbOpts: { - kbExpr: EditorContextKeys.focus, - primary: KeyMod.Alt | KeyCode.F9, - weight: KeybindingWeight.EditorContrib - } - }); - } - public run(accessor: ServicesAccessor, editor: ICodeEditor): void { - const controller = CommentController.get(editor); - controller?.nextCommentThread(); - } -} +export const NEXT_COMMENT_THREAD_COMMAND_ID = 'workbench.action.nextCommentThread'; +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: NEXT_COMMENT_THREAD_COMMAND_ID, + handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { + const activeEditor = getActiveEditor(accessor); + if (!activeEditor) { + return Promise.resolve(); + } -export class PreviousCommentThreadAction extends EditorAction { - static ID: string = 'editor.action.previousCommentThread'; - constructor() { - super({ - id: ID, - label: nls.localize('previousCommentThreadAction', "Go to Previous Comment Thread"), - alias: 'Go to Previous Comment Thread', - precondition: undefined, - kbOpts: { - kbExpr: EditorContextKeys.focus, - primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F9, - weight: KeybindingWeight.EditorContrib - } - }); - } + const controller = CommentController.get(activeEditor); + if (!controller) { + return Promise.resolve(); + } + controller.nextCommentThread(); + }, + weight: KeybindingWeight.EditorContrib, + when: EditorContextKeys.focus, + primary: KeyMod.Alt | KeyCode.F9, +}); + +export const PREVIOUS_COMMENT_THREAD_COMMAND_ID = 'workbench.action.previousCommentThread'; +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: PREVIOUS_COMMENT_THREAD_COMMAND_ID, + handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { + const activeEditor = getActiveEditor(accessor); + if (!activeEditor) { + return Promise.resolve(); + } + + const controller = CommentController.get(activeEditor); + if (!controller) { + return Promise.resolve(); + } + controller.previousCommentThread(); + }, + weight: KeybindingWeight.EditorContrib, + when: EditorContextKeys.focus, + primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F9 +}); - public run(accessor: ServicesAccessor, editor: ICodeEditor): void { - const controller = CommentController.get(editor); - controller?.previousCommentThread(); - } -} registerEditorContribution(ID, CommentController, EditorContributionInstantiation.AfterFirstRender); -registerEditorAction(NextCommentThreadAction); -registerEditorAction(PreviousCommentThreadAction); - -export class NextCommentingRangeAction extends EditorAction { - static ID: string = 'editor.action.goToNextCommentingRange'; - constructor() { - super({ - id: ID, - label: nls.localize('goToNextCommentingRange', "Go to Next Commenting Range"), - alias: 'Go to Next Commenting Range', - precondition: CommentContextKeys.WorkspaceHasCommenting, - kbOpts: { - kbExpr: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ContextKeyExpr.and(accessibilityHelpIsShown, accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Comments)))), - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.DownArrow), - weight: KeybindingWeight.EditorContrib - } - }); - } - public run(accessor: ServicesAccessor, editor: ICodeEditor): void { - const controller = CommentController.get(editor); - controller?.nextCommentingRange(); - } -} -export class PreviousCommentingRangeAction extends EditorAction { - static ID: 'editor.action.goToPreviousCommentingRange'; - constructor() { - super({ - id: ID, - label: nls.localize('goToPreviousCommentingRange', "Go to Previous Commenting Range"), - alias: 'Go to Next Commenting Range', - precondition: CommentContextKeys.WorkspaceHasCommenting, - kbOpts: { - kbExpr: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ContextKeyExpr.and(accessibilityHelpIsShown, accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Comments)))), - primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.UpArrow), - weight: KeybindingWeight.EditorContrib - } - }); - } +export const NEXT_COMMENT_RANGE_COMMAND_ID = 'workbench.action.nextCommentRange'; +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: NEXT_COMMENT_RANGE_COMMAND_ID, + handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { + const activeEditor = getActiveEditor(accessor); + if (!activeEditor) { + return Promise.resolve(); + } - public run(accessor: ServicesAccessor, editor: ICodeEditor): void { - const controller = CommentController.get(editor); - controller?.previousCommentingRange(); - } -} + const controller = CommentController.get(activeEditor); + if (!controller) { + return Promise.resolve(); + } + controller.nextCommentingRange(); + }, + when: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ContextKeyExpr.and(accessibilityHelpIsShown, accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Comments)))), + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.DownArrow), + weight: KeybindingWeight.EditorContrib +}); + +export const PREVIOUS_COMMENT_RANGE_COMMAND_ID = 'workbench.action.previousCommentRange'; +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: PREVIOUS_COMMENT_RANGE_COMMAND_ID, + handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { + const activeEditor = getActiveEditor(accessor); + if (!activeEditor) { + return Promise.resolve(); + } -registerEditorAction(NextCommentingRangeAction); -registerEditorAction(PreviousCommentingRangeAction); + const controller = CommentController.get(activeEditor); + if (!controller) { + return Promise.resolve(); + } + controller.previousCommentingRange(); + }, + when: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ContextKeyExpr.and(accessibilityHelpIsShown, accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Comments)))), + primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.UpArrow), + weight: KeybindingWeight.EditorContrib +}); const TOGGLE_COMMENTING_COMMAND = 'workbench.action.toggleCommenting'; CommandsRegistry.registerCommand({ From d5411935e99d0e14a72358c38a9e95d5b6124d57 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Tue, 19 Sep 2023 14:56:25 -0700 Subject: [PATCH 08/15] make CommentCommandId enum --- .../browser/accessibilityContributions.ts | 12 ++-- .../comments/browser/comments.contribution.ts | 10 +-- .../browser/commentsEditorContribution.ts | 61 ++++++++++--------- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts index 8a0761f9c74ea..4007d5eaa7809 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts @@ -39,8 +39,8 @@ import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys'; import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import { ADD_COMMENT_COMMAND, NEXT_COMMENT_RANGE_COMMAND_ID, NEXT_COMMENT_THREAD_COMMAND_ID, PREVIOUS_COMMENT_RANGE_COMMAND_ID, PREVIOUS_COMMENT_THREAD_COMMAND_ID } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; import { CommentAccessibilityHelpNLS } from 'vs/workbench/contrib/comments/browser/comments.contribution'; +import { CommentCommandId } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; export class EditorAccessibilityHelpContribution extends Disposable { static ID: 'editorAccessibilityHelpContribution'; @@ -101,11 +101,11 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider { } if (this._contextKeyService.getContextKeyValue(CommentContextKeys.activeEditorHasCommentingRange.key)) { - content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(NEXT_COMMENT_THREAD_COMMAND_ID, CommentAccessibilityHelpNLS.nextCommentThreadKb, CommentAccessibilityHelpNLS.nextCommentThreadNoKb)); - content.push(this._descriptionForCommand(PREVIOUS_COMMENT_THREAD_COMMAND_ID, CommentAccessibilityHelpNLS.previousCommentThreadKb, CommentAccessibilityHelpNLS.previousCommentThreadNoKb)); - content.push(this._descriptionForCommand(NEXT_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); - content.push(this._descriptionForCommand(PREVIOUS_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.NextThread, CommentAccessibilityHelpNLS.nextCommentThreadKb, CommentAccessibilityHelpNLS.nextCommentThreadNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.PreviousThread, CommentAccessibilityHelpNLS.previousCommentThreadKb, CommentAccessibilityHelpNLS.previousCommentThreadNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); } if (options.get(EditorOption.stickyScroll).enabled) { diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index 4c3c94875bb95..af171915539f7 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -18,7 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import { ADD_COMMENT_COMMAND, NEXT_COMMENT_RANGE_COMMAND_ID, PREVIOUS_COMMENT_RANGE_COMMAND_ID, SUBMIT_COMMENT_COMMAND_ID } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { CommentCommandId } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ @@ -115,10 +115,10 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv this._element = document.activeElement as HTMLElement; const content: string[] = []; content.push(CommentAccessibilityHelpNLS.escape); - content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(NEXT_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); - content.push(this._descriptionForCommand(PREVIOUS_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); - content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.Submit, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); return content.join('\n\n'); } onClose(): void { diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 30035118a402f..b883750ade273 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -25,10 +25,24 @@ import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/co import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { accessibilityHelpIsShown, accessibleViewCurrentProviderId, AccessibleViewProviderId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; +registerEditorContribution(ID, CommentController, EditorContributionInstantiation.AfterFirstRender); + +export const enum CommentCommandId { + Add = 'editor.action.addComment', + NextThread = 'workbench.action.nextCommentThreadAction', + PreviousThread = 'workbench.action.previousCommentThreadAction', + NextRange = 'workbench.action.nextCommentRange', + PreviousRange = 'workbench.action.previousCommentRange', + ToggleCommenting = 'workbench.action.toggleCommenting', + Submit = 'editor.action.submitComment', + Hide = 'workbench.action.hideComment', + CollapseAll = 'workbench.action.collapseAllComments', + ExpandAll = 'workbench.action.expandAllComments', + ExpandUnresolved = 'workbench.action.expandUnresolvedComments' +} -export const NEXT_COMMENT_THREAD_COMMAND_ID = 'workbench.action.nextCommentThread'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: NEXT_COMMENT_THREAD_COMMAND_ID, + id: CommentCommandId.NextThread, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { const activeEditor = getActiveEditor(accessor); if (!activeEditor) { @@ -46,9 +60,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ primary: KeyMod.Alt | KeyCode.F9, }); -export const PREVIOUS_COMMENT_THREAD_COMMAND_ID = 'workbench.action.previousCommentThread'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: PREVIOUS_COMMENT_THREAD_COMMAND_ID, + id: CommentCommandId.PreviousThread, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { const activeEditor = getActiveEditor(accessor); if (!activeEditor) { @@ -66,13 +79,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F9 }); - -registerEditorContribution(ID, CommentController, EditorContributionInstantiation.AfterFirstRender); - - -export const NEXT_COMMENT_RANGE_COMMAND_ID = 'workbench.action.nextCommentRange'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: NEXT_COMMENT_RANGE_COMMAND_ID, + id: CommentCommandId.NextRange, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { const activeEditor = getActiveEditor(accessor); if (!activeEditor) { @@ -90,9 +98,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: KeybindingWeight.EditorContrib }); -export const PREVIOUS_COMMENT_RANGE_COMMAND_ID = 'workbench.action.previousCommentRange'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: PREVIOUS_COMMENT_RANGE_COMMAND_ID, + id: CommentCommandId.PreviousRange, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { const activeEditor = getActiveEditor(accessor); if (!activeEditor) { @@ -110,9 +117,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: KeybindingWeight.EditorContrib }); -const TOGGLE_COMMENTING_COMMAND = 'workbench.action.toggleCommenting'; CommandsRegistry.registerCommand({ - id: TOGGLE_COMMENTING_COMMAND, + id: CommentCommandId.ToggleCommenting, handler: (accessor) => { const commentService = accessor.get(ICommentService); const enable = commentService.isCommentingEnabled; @@ -122,16 +128,15 @@ CommandsRegistry.registerCommand({ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { - id: TOGGLE_COMMENTING_COMMAND, + id: CommentCommandId.ToggleCommenting, title: nls.localize('comments.toggleCommenting', "Toggle Editor Commenting"), category: 'Comments', }, when: CommentContextKeys.WorkspaceHasCommenting }); -export const ADD_COMMENT_COMMAND = 'workbench.action.addComment'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: ADD_COMMENT_COMMAND, + id: CommentCommandId.Add, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { const activeEditor = getActiveEditor(accessor); if (!activeEditor) { @@ -158,16 +163,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { - id: ADD_COMMENT_COMMAND, + id: CommentCommandId.Add, title: nls.localize('comments.addCommand', "Add Comment on Current Selection"), category: 'Comments' }, when: CommentContextKeys.activeCursorHasCommentingRange }); -const COLLAPSE_ALL_COMMENT_COMMAND = 'workbench.action.collapseAllComments'; CommandsRegistry.registerCommand({ - id: COLLAPSE_ALL_COMMENT_COMMAND, + id: CommentCommandId.CollapseAll, handler: (accessor) => { return getActiveController(accessor)?.collapseAll(); } @@ -175,16 +179,15 @@ CommandsRegistry.registerCommand({ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { - id: COLLAPSE_ALL_COMMENT_COMMAND, + id: CommentCommandId.CollapseAll, title: nls.localize('comments.collapseAll', "Collapse All Comments"), category: 'Comments' }, when: CommentContextKeys.WorkspaceHasCommenting }); -const EXPAND_ALL_COMMENT_COMMAND = 'workbench.action.expandAllComments'; CommandsRegistry.registerCommand({ - id: EXPAND_ALL_COMMENT_COMMAND, + id: CommentCommandId.ExpandAll, handler: (accessor) => { return getActiveController(accessor)?.expandAll(); } @@ -192,16 +195,15 @@ CommandsRegistry.registerCommand({ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { - id: EXPAND_ALL_COMMENT_COMMAND, + id: CommentCommandId.ExpandAll, title: nls.localize('comments.expandAll', "Expand All Comments"), category: 'Comments' }, when: CommentContextKeys.WorkspaceHasCommenting }); -const EXPAND_UNRESOLVED_COMMENT_COMMAND = 'workbench.action.expandUnresolvedComments'; CommandsRegistry.registerCommand({ - id: EXPAND_UNRESOLVED_COMMENT_COMMAND, + id: CommentCommandId.ExpandUnresolved, handler: (accessor) => { return getActiveController(accessor)?.expandUnresolved(); } @@ -209,16 +211,15 @@ CommandsRegistry.registerCommand({ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { - id: EXPAND_UNRESOLVED_COMMENT_COMMAND, + id: CommentCommandId.ExpandUnresolved, title: nls.localize('comments.expandUnresolved', "Expand Unresolved Comments"), category: 'Comments' }, when: CommentContextKeys.WorkspaceHasCommenting }); -export const SUBMIT_COMMENT_COMMAND_ID = 'workbench.action.submitComment'; KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: SUBMIT_COMMENT_COMMAND_ID, + id: CommentCommandId.Submit, weight: KeybindingWeight.EditorContrib, primary: KeyMod.CtrlCmd | KeyCode.Enter, when: ctxCommentEditorFocused, @@ -231,7 +232,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); KeybindingsRegistry.registerCommandAndKeybindingRule({ - id: 'workbench.action.hideComment', + id: CommentCommandId.Hide, weight: KeybindingWeight.EditorContrib, primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], From acb9372029b3a09aba9b633d6fc54f1be62c0097 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 20 Sep 2023 08:37:37 -0700 Subject: [PATCH 09/15] Update src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts Co-authored-by: Alex Ross --- .../contrib/comments/browser/commentsEditorContribution.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index b883750ade273..3fe033daee54e 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -31,8 +31,8 @@ export const enum CommentCommandId { Add = 'editor.action.addComment', NextThread = 'workbench.action.nextCommentThreadAction', PreviousThread = 'workbench.action.previousCommentThreadAction', - NextRange = 'workbench.action.nextCommentRange', - PreviousRange = 'workbench.action.previousCommentRange', + NextRange = 'editor.action.nextCommentingRange', + PreviousRange = 'editor.action.previousCommentingRange', ToggleCommenting = 'workbench.action.toggleCommenting', Submit = 'editor.action.submitComment', Hide = 'workbench.action.hideComment', From 3447de2630bf0a637ca32b3a5a6992c93eb6ffc9 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 20 Sep 2023 08:37:45 -0700 Subject: [PATCH 10/15] Update src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts Co-authored-by: Alex Ross --- .../contrib/comments/browser/commentsEditorContribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 3fe033daee54e..e9cd30f2037ad 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -29,7 +29,7 @@ registerEditorContribution(ID, CommentController, EditorContributionInstantiatio export const enum CommentCommandId { Add = 'editor.action.addComment', - NextThread = 'workbench.action.nextCommentThreadAction', + NextThread = 'editor.action.nextCommentThreadAction', PreviousThread = 'workbench.action.previousCommentThreadAction', NextRange = 'editor.action.nextCommentingRange', PreviousRange = 'editor.action.previousCommentingRange', From ccdb6a802b1c9ec4d6e2de80eb6d043ec4562809 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 20 Sep 2023 08:37:56 -0700 Subject: [PATCH 11/15] Update src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts Co-authored-by: Alex Ross --- .../contrib/comments/browser/commentsEditorContribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index e9cd30f2037ad..bc117fb57e3c4 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -28,7 +28,7 @@ import { accessibilityHelpIsShown, accessibleViewCurrentProviderId, AccessibleVi registerEditorContribution(ID, CommentController, EditorContributionInstantiation.AfterFirstRender); export const enum CommentCommandId { - Add = 'editor.action.addComment', + Add = 'workbench.action.addComment', NextThread = 'editor.action.nextCommentThreadAction', PreviousThread = 'workbench.action.previousCommentThreadAction', NextRange = 'editor.action.nextCommentingRange', From e727bc9e99a81a7c69fa1b5aab49b92a2fbfb7be Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 20 Sep 2023 08:38:07 -0700 Subject: [PATCH 12/15] Update src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts Co-authored-by: Alex Ross --- .../contrib/comments/browser/commentsEditorContribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index bc117fb57e3c4..01b30bafc1ed7 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -30,7 +30,7 @@ registerEditorContribution(ID, CommentController, EditorContributionInstantiatio export const enum CommentCommandId { Add = 'workbench.action.addComment', NextThread = 'editor.action.nextCommentThreadAction', - PreviousThread = 'workbench.action.previousCommentThreadAction', + PreviousThread = 'editor.action.previousCommentThreadAction', NextRange = 'editor.action.nextCommentingRange', PreviousRange = 'editor.action.previousCommentingRange', ToggleCommenting = 'workbench.action.toggleCommenting', From 999e245c52594b33f915bac88b251fc477c1238c Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 20 Sep 2023 08:50:13 -0700 Subject: [PATCH 13/15] import all from contribution file --- .../contrib/comments/browser/comments.contribution.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index af171915539f7..77929095ec0a4 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -18,8 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import { CommentCommandId } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; - +import * as commentsEditorContribution from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ id: 'comments', @@ -115,10 +114,10 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv this._element = document.activeElement as HTMLElement; const content: string[] = []; content.push(CommentAccessibilityHelpNLS.escape); - content.push(this._descriptionForCommand(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); - content.push(this._descriptionForCommand(CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); - content.push(this._descriptionForCommand(CommentCommandId.Submit, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); + content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); + content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.Submit, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); return content.join('\n\n'); } onClose(): void { From 75d99c4f8cc143e18ab5ba6e4bced863a2931a43 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Wed, 20 Sep 2023 13:09:56 -0700 Subject: [PATCH 14/15] create comment command ids --- .../browser/accessibilityContributions.ts | 2 +- .../comments/browser/comments.contribution.ts | 11 ++++++----- .../browser/commentsEditorContribution.ts | 15 +-------------- .../comments/common/commentCommandIds.ts | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 src/vs/workbench/contrib/comments/common/commentCommandIds.ts diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts index 4007d5eaa7809..853edf83b7e8f 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts @@ -40,7 +40,7 @@ import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; import { CommentAccessibilityHelpNLS } from 'vs/workbench/contrib/comments/browser/comments.contribution'; -import { CommentCommandId } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { CommentCommandId } from 'vs/workbench/contrib/comments/common/commentCommandIds'; export class EditorAccessibilityHelpContribution extends Disposable { static ID: 'editorAccessibilityHelpContribution'; diff --git a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts index 77929095ec0a4..a7e9ee0999504 100644 --- a/src/vs/workbench/contrib/comments/browser/comments.contribution.ts +++ b/src/vs/workbench/contrib/comments/browser/comments.contribution.ts @@ -6,6 +6,7 @@ import * as nls from 'vs/nls'; import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { Registry } from 'vs/platform/registry/common/platform'; +import 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; import { ICommentService, CommentService } from 'vs/workbench/contrib/comments/browser/commentService'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; import { ctxCommentEditorFocused } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; @@ -18,7 +19,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; -import * as commentsEditorContribution from 'vs/workbench/contrib/comments/browser/commentsEditorContribution'; +import { CommentCommandId } from 'vs/workbench/contrib/comments/common/commentCommandIds'; Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ id: 'comments', @@ -114,10 +115,10 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv this._element = document.activeElement as HTMLElement; const content: string[] = []; content.push(CommentAccessibilityHelpNLS.escape); - content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); - content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); - content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); - content.push(this._descriptionForCommand(commentsEditorContribution.CommentCommandId.Submit, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb)); + content.push(this._descriptionForCommand(CommentCommandId.Submit, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); return content.join('\n\n'); } onClose(): void { diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 01b30bafc1ed7..be0a96f0d634f 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -24,23 +24,10 @@ import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/comment import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { accessibilityHelpIsShown, accessibleViewCurrentProviderId, AccessibleViewProviderId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration'; +import { CommentCommandId } from 'vs/workbench/contrib/comments/common/commentCommandIds'; registerEditorContribution(ID, CommentController, EditorContributionInstantiation.AfterFirstRender); -export const enum CommentCommandId { - Add = 'workbench.action.addComment', - NextThread = 'editor.action.nextCommentThreadAction', - PreviousThread = 'editor.action.previousCommentThreadAction', - NextRange = 'editor.action.nextCommentingRange', - PreviousRange = 'editor.action.previousCommentingRange', - ToggleCommenting = 'workbench.action.toggleCommenting', - Submit = 'editor.action.submitComment', - Hide = 'workbench.action.hideComment', - CollapseAll = 'workbench.action.collapseAllComments', - ExpandAll = 'workbench.action.expandAllComments', - ExpandUnresolved = 'workbench.action.expandUnresolvedComments' -} - KeybindingsRegistry.registerCommandAndKeybindingRule({ id: CommentCommandId.NextThread, handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => { diff --git a/src/vs/workbench/contrib/comments/common/commentCommandIds.ts b/src/vs/workbench/contrib/comments/common/commentCommandIds.ts new file mode 100644 index 0000000000000..8f0c14875de25 --- /dev/null +++ b/src/vs/workbench/contrib/comments/common/commentCommandIds.ts @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export const enum CommentCommandId { + Add = 'workbench.action.addComment', + NextThread = 'editor.action.nextCommentThreadAction', + PreviousThread = 'editor.action.previousCommentThreadAction', + NextRange = 'editor.action.nextCommentingRange', + PreviousRange = 'editor.action.previousCommentingRange', + ToggleCommenting = 'workbench.action.toggleCommenting', + Submit = 'editor.action.submitComment', + Hide = 'workbench.action.hideComment', + CollapseAll = 'workbench.action.collapseAllComments', + ExpandAll = 'workbench.action.expandAllComments', + ExpandUnresolved = 'workbench.action.expandUnresolvedComments' +} From d30859f19c4b88eb9f367fea35d3f22604c54ac4 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Thu, 21 Sep 2023 07:10:23 -0700 Subject: [PATCH 15/15] Update accessibilityContributions.ts Co-authored-by: Alex Ross --- .../accessibility/browser/accessibilityContributions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts index 853edf83b7e8f..0c245548ad0a8 100644 --- a/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts +++ b/src/vs/workbench/contrib/accessibility/browser/accessibilityContributions.ts @@ -100,7 +100,8 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider { } } - if (this._contextKeyService.getContextKeyValue(CommentContextKeys.activeEditorHasCommentingRange.key)) { + const editorContext = this._contextKeyService.getContext(this._editor.getDomNode()!); + if (editorContext.getValue(CommentContextKeys.activeEditorHasCommentingRange.key)) { content.push(this._descriptionForCommand(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); content.push(this._descriptionForCommand(CommentCommandId.NextThread, CommentAccessibilityHelpNLS.nextCommentThreadKb, CommentAccessibilityHelpNLS.nextCommentThreadNoKb)); content.push(this._descriptionForCommand(CommentCommandId.PreviousThread, CommentAccessibilityHelpNLS.previousCommentThreadKb, CommentAccessibilityHelpNLS.previousCommentThreadNoKb));