add to editor help menu

This commit is contained in:
meganrogge
2023-09-19 13:51:25 -07:00
parent e49c56aab8
commit e252fd620b
3 changed files with 28 additions and 10 deletions

View File

@@ -37,7 +37,10 @@ import { ThemeIcon } from 'vs/base/common/themables';
import { Codicon } from 'vs/base/common/codicons'; import { Codicon } from 'vs/base/common/codicons';
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController'; import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys'; 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 { export class EditorAccessibilityHelpContribution extends Disposable {
static ID: 'editorAccessibilityHelpContribution'; static ID: 'editorAccessibilityHelpContribution';
@@ -66,7 +69,8 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider {
verbositySettingKey = AccessibilityVerbositySettingId.Editor; verbositySettingKey = AccessibilityVerbositySettingId.Editor;
constructor( constructor(
private readonly _editor: ICodeEditor, 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<boolean>(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) { if (options.get(EditorOption.stickyScroll).enabled) {
content.push(this._descriptionForCommand('editor.action.focusStickyScroll', AccessibilityHelpNLS.stickScrollKb, AccessibilityHelpNLS.stickScrollNoKb)); content.push(this._descriptionForCommand('editor.action.focusStickyScroll', AccessibilityHelpNLS.stickScrollKb, AccessibilityHelpNLS.stickScrollNoKb));
} }

View File

@@ -119,7 +119,11 @@ export class CommentThreadWidget<T extends IRange | ICellRange = IRange> extends
})); }));
this._register(tracker.onDidFocus(() => this._focusedContextKey.set(true))); this._register(tracker.onDidFocus(() => this._focusedContextKey.set(true)));
this._register(tracker.onDidBlur(() => this._focusedContextKey.reset())); 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( this._body = this._scopedInstantiationService.createInstance(
CommentThreadBody, CommentThreadBody,
this._owner, this._owner,

View File

@@ -67,12 +67,16 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
registerSingleton(ICommentService, CommentService, InstantiationType.Delayed); registerSingleton(ICommentService, CommentService, InstantiationType.Delayed);
namespace CommentAccessibilityHelpNLS { export namespace CommentAccessibilityHelpNLS {
export const escape = nls.localize('escape', "Dismiss the comment widget via Escape."); 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 nextRange = 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 nextRangeNoKb = 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 previousRange = 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 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 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 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 submitComment = nls.localize('submitComment', "Submit the comment via ({0}).");
@@ -112,8 +116,8 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv
const content: string[] = []; const content: string[] = [];
content.push(CommentAccessibilityHelpNLS.escape); content.push(CommentAccessibilityHelpNLS.escape);
content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb)); 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(NextCommentingRangeAction.ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb));
content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previous, CommentAccessibilityHelpNLS.previousNoKb)); content.push(this._descriptionForCommand(PreviousCommentingRangeAction.ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb));
content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb)); content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb));
return content.join('\n\n'); return content.join('\n\n');
} }