mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
make CommentCommandId enum
This commit is contained in:
@@ -39,8 +39,8 @@ import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions
|
|||||||
import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys';
|
import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys';
|
||||||
import { ContextKeyExpr, IContextKeyService } 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 { 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 { CommentAccessibilityHelpNLS } from 'vs/workbench/contrib/comments/browser/comments.contribution';
|
||||||
|
import { CommentCommandId } from 'vs/workbench/contrib/comments/browser/commentsEditorContribution';
|
||||||
|
|
||||||
export class EditorAccessibilityHelpContribution extends Disposable {
|
export class EditorAccessibilityHelpContribution extends Disposable {
|
||||||
static ID: 'editorAccessibilityHelpContribution';
|
static ID: 'editorAccessibilityHelpContribution';
|
||||||
@@ -101,11 +101,11 @@ class AccessibilityHelpProvider implements IAccessibleContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._contextKeyService.getContextKeyValue<boolean>(CommentContextKeys.activeEditorHasCommentingRange.key)) {
|
if (this._contextKeyService.getContextKeyValue<boolean>(CommentContextKeys.activeEditorHasCommentingRange.key)) {
|
||||||
content.push(this._descriptionForCommand(ADD_COMMENT_COMMAND, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb));
|
||||||
content.push(this._descriptionForCommand(NEXT_COMMENT_THREAD_COMMAND_ID, CommentAccessibilityHelpNLS.nextCommentThreadKb, CommentAccessibilityHelpNLS.nextCommentThreadNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.NextThread, CommentAccessibilityHelpNLS.nextCommentThreadKb, CommentAccessibilityHelpNLS.nextCommentThreadNoKb));
|
||||||
content.push(this._descriptionForCommand(PREVIOUS_COMMENT_THREAD_COMMAND_ID, CommentAccessibilityHelpNLS.previousCommentThreadKb, CommentAccessibilityHelpNLS.previousCommentThreadNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.PreviousThread, CommentAccessibilityHelpNLS.previousCommentThreadKb, CommentAccessibilityHelpNLS.previousCommentThreadNoKb));
|
||||||
content.push(this._descriptionForCommand(NEXT_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb));
|
||||||
content.push(this._descriptionForCommand(PREVIOUS_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.get(EditorOption.stickyScroll).enabled) {
|
if (options.get(EditorOption.stickyScroll).enabled) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
|||||||
import { Disposable } from 'vs/base/common/lifecycle';
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys';
|
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<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
|
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
|
||||||
@@ -115,10 +115,10 @@ export class CommentsAccessibilityHelpProvider implements IAccessibleContentProv
|
|||||||
this._element = document.activeElement as HTMLElement;
|
this._element = document.activeElement as HTMLElement;
|
||||||
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(CommentCommandId.Add, CommentAccessibilityHelpNLS.addComment, CommentAccessibilityHelpNLS.addCommentNoKb));
|
||||||
content.push(this._descriptionForCommand(NEXT_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.NextRange, CommentAccessibilityHelpNLS.nextRange, CommentAccessibilityHelpNLS.nextRangeNoKb));
|
||||||
content.push(this._descriptionForCommand(PREVIOUS_COMMENT_RANGE_COMMAND_ID, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.PreviousRange, CommentAccessibilityHelpNLS.previousRange, CommentAccessibilityHelpNLS.previousRangeNoKb));
|
||||||
content.push(this._descriptionForCommand(SUBMIT_COMMENT_COMMAND_ID, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb));
|
content.push(this._descriptionForCommand(CommentCommandId.Submit, CommentAccessibilityHelpNLS.submitComment, CommentAccessibilityHelpNLS.submitCommentNoKb));
|
||||||
return content.join('\n\n');
|
return content.join('\n\n');
|
||||||
}
|
}
|
||||||
onClose(): void {
|
onClose(): void {
|
||||||
|
|||||||
@@ -25,10 +25,24 @@ import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/co
|
|||||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { accessibilityHelpIsShown, accessibleViewCurrentProviderId, AccessibleViewProviderId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
|
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({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: NEXT_COMMENT_THREAD_COMMAND_ID,
|
id: CommentCommandId.NextThread,
|
||||||
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
||||||
const activeEditor = getActiveEditor(accessor);
|
const activeEditor = getActiveEditor(accessor);
|
||||||
if (!activeEditor) {
|
if (!activeEditor) {
|
||||||
@@ -46,9 +60,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
primary: KeyMod.Alt | KeyCode.F9,
|
primary: KeyMod.Alt | KeyCode.F9,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PREVIOUS_COMMENT_THREAD_COMMAND_ID = 'workbench.action.previousCommentThread';
|
|
||||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: PREVIOUS_COMMENT_THREAD_COMMAND_ID,
|
id: CommentCommandId.PreviousThread,
|
||||||
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
||||||
const activeEditor = getActiveEditor(accessor);
|
const activeEditor = getActiveEditor(accessor);
|
||||||
if (!activeEditor) {
|
if (!activeEditor) {
|
||||||
@@ -66,13 +79,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F9
|
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F9
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
registerEditorContribution(ID, CommentController, EditorContributionInstantiation.AfterFirstRender);
|
|
||||||
|
|
||||||
|
|
||||||
export const NEXT_COMMENT_RANGE_COMMAND_ID = 'workbench.action.nextCommentRange';
|
|
||||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: NEXT_COMMENT_RANGE_COMMAND_ID,
|
id: CommentCommandId.NextRange,
|
||||||
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
||||||
const activeEditor = getActiveEditor(accessor);
|
const activeEditor = getActiveEditor(accessor);
|
||||||
if (!activeEditor) {
|
if (!activeEditor) {
|
||||||
@@ -90,9 +98,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
weight: KeybindingWeight.EditorContrib
|
weight: KeybindingWeight.EditorContrib
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PREVIOUS_COMMENT_RANGE_COMMAND_ID = 'workbench.action.previousCommentRange';
|
|
||||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: PREVIOUS_COMMENT_RANGE_COMMAND_ID,
|
id: CommentCommandId.PreviousRange,
|
||||||
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
||||||
const activeEditor = getActiveEditor(accessor);
|
const activeEditor = getActiveEditor(accessor);
|
||||||
if (!activeEditor) {
|
if (!activeEditor) {
|
||||||
@@ -110,9 +117,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
weight: KeybindingWeight.EditorContrib
|
weight: KeybindingWeight.EditorContrib
|
||||||
});
|
});
|
||||||
|
|
||||||
const TOGGLE_COMMENTING_COMMAND = 'workbench.action.toggleCommenting';
|
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: TOGGLE_COMMENTING_COMMAND,
|
id: CommentCommandId.ToggleCommenting,
|
||||||
handler: (accessor) => {
|
handler: (accessor) => {
|
||||||
const commentService = accessor.get(ICommentService);
|
const commentService = accessor.get(ICommentService);
|
||||||
const enable = commentService.isCommentingEnabled;
|
const enable = commentService.isCommentingEnabled;
|
||||||
@@ -122,16 +128,15 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||||
command: {
|
command: {
|
||||||
id: TOGGLE_COMMENTING_COMMAND,
|
id: CommentCommandId.ToggleCommenting,
|
||||||
title: nls.localize('comments.toggleCommenting', "Toggle Editor Commenting"),
|
title: nls.localize('comments.toggleCommenting', "Toggle Editor Commenting"),
|
||||||
category: 'Comments',
|
category: 'Comments',
|
||||||
},
|
},
|
||||||
when: CommentContextKeys.WorkspaceHasCommenting
|
when: CommentContextKeys.WorkspaceHasCommenting
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ADD_COMMENT_COMMAND = 'workbench.action.addComment';
|
|
||||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: ADD_COMMENT_COMMAND,
|
id: CommentCommandId.Add,
|
||||||
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
handler: async (accessor, args?: { range: IRange; fileComment: boolean }) => {
|
||||||
const activeEditor = getActiveEditor(accessor);
|
const activeEditor = getActiveEditor(accessor);
|
||||||
if (!activeEditor) {
|
if (!activeEditor) {
|
||||||
@@ -158,16 +163,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||||
command: {
|
command: {
|
||||||
id: ADD_COMMENT_COMMAND,
|
id: CommentCommandId.Add,
|
||||||
title: nls.localize('comments.addCommand', "Add Comment on Current Selection"),
|
title: nls.localize('comments.addCommand', "Add Comment on Current Selection"),
|
||||||
category: 'Comments'
|
category: 'Comments'
|
||||||
},
|
},
|
||||||
when: CommentContextKeys.activeCursorHasCommentingRange
|
when: CommentContextKeys.activeCursorHasCommentingRange
|
||||||
});
|
});
|
||||||
|
|
||||||
const COLLAPSE_ALL_COMMENT_COMMAND = 'workbench.action.collapseAllComments';
|
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: COLLAPSE_ALL_COMMENT_COMMAND,
|
id: CommentCommandId.CollapseAll,
|
||||||
handler: (accessor) => {
|
handler: (accessor) => {
|
||||||
return getActiveController(accessor)?.collapseAll();
|
return getActiveController(accessor)?.collapseAll();
|
||||||
}
|
}
|
||||||
@@ -175,16 +179,15 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||||
command: {
|
command: {
|
||||||
id: COLLAPSE_ALL_COMMENT_COMMAND,
|
id: CommentCommandId.CollapseAll,
|
||||||
title: nls.localize('comments.collapseAll', "Collapse All Comments"),
|
title: nls.localize('comments.collapseAll', "Collapse All Comments"),
|
||||||
category: 'Comments'
|
category: 'Comments'
|
||||||
},
|
},
|
||||||
when: CommentContextKeys.WorkspaceHasCommenting
|
when: CommentContextKeys.WorkspaceHasCommenting
|
||||||
});
|
});
|
||||||
|
|
||||||
const EXPAND_ALL_COMMENT_COMMAND = 'workbench.action.expandAllComments';
|
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: EXPAND_ALL_COMMENT_COMMAND,
|
id: CommentCommandId.ExpandAll,
|
||||||
handler: (accessor) => {
|
handler: (accessor) => {
|
||||||
return getActiveController(accessor)?.expandAll();
|
return getActiveController(accessor)?.expandAll();
|
||||||
}
|
}
|
||||||
@@ -192,16 +195,15 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||||
command: {
|
command: {
|
||||||
id: EXPAND_ALL_COMMENT_COMMAND,
|
id: CommentCommandId.ExpandAll,
|
||||||
title: nls.localize('comments.expandAll', "Expand All Comments"),
|
title: nls.localize('comments.expandAll', "Expand All Comments"),
|
||||||
category: 'Comments'
|
category: 'Comments'
|
||||||
},
|
},
|
||||||
when: CommentContextKeys.WorkspaceHasCommenting
|
when: CommentContextKeys.WorkspaceHasCommenting
|
||||||
});
|
});
|
||||||
|
|
||||||
const EXPAND_UNRESOLVED_COMMENT_COMMAND = 'workbench.action.expandUnresolvedComments';
|
|
||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: EXPAND_UNRESOLVED_COMMENT_COMMAND,
|
id: CommentCommandId.ExpandUnresolved,
|
||||||
handler: (accessor) => {
|
handler: (accessor) => {
|
||||||
return getActiveController(accessor)?.expandUnresolved();
|
return getActiveController(accessor)?.expandUnresolved();
|
||||||
}
|
}
|
||||||
@@ -209,16 +211,15 @@ CommandsRegistry.registerCommand({
|
|||||||
|
|
||||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||||
command: {
|
command: {
|
||||||
id: EXPAND_UNRESOLVED_COMMENT_COMMAND,
|
id: CommentCommandId.ExpandUnresolved,
|
||||||
title: nls.localize('comments.expandUnresolved', "Expand Unresolved Comments"),
|
title: nls.localize('comments.expandUnresolved', "Expand Unresolved Comments"),
|
||||||
category: 'Comments'
|
category: 'Comments'
|
||||||
},
|
},
|
||||||
when: CommentContextKeys.WorkspaceHasCommenting
|
when: CommentContextKeys.WorkspaceHasCommenting
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SUBMIT_COMMENT_COMMAND_ID = 'workbench.action.submitComment';
|
|
||||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: SUBMIT_COMMENT_COMMAND_ID,
|
id: CommentCommandId.Submit,
|
||||||
weight: KeybindingWeight.EditorContrib,
|
weight: KeybindingWeight.EditorContrib,
|
||||||
primary: KeyMod.CtrlCmd | KeyCode.Enter,
|
primary: KeyMod.CtrlCmd | KeyCode.Enter,
|
||||||
when: ctxCommentEditorFocused,
|
when: ctxCommentEditorFocused,
|
||||||
@@ -231,7 +232,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
});
|
});
|
||||||
|
|
||||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
id: 'workbench.action.hideComment',
|
id: CommentCommandId.Hide,
|
||||||
weight: KeybindingWeight.EditorContrib,
|
weight: KeybindingWeight.EditorContrib,
|
||||||
primary: KeyCode.Escape,
|
primary: KeyCode.Escape,
|
||||||
secondary: [KeyMod.Shift | KeyCode.Escape],
|
secondary: [KeyMod.Shift | KeyCode.Escape],
|
||||||
|
|||||||
Reference in New Issue
Block a user