Skip to content

Commit 351e07b

Browse files
authored
Error: Cannot register two commands with the same id: workbench.action.focusCommentsPanel (microsoft#202596)
Fixes microsoft#202563
1 parent f64beed commit 351e07b

File tree

2 files changed

+63
-61
lines changed

2 files changed

+63
-61
lines changed

src/vs/workbench/contrib/comments/browser/comments.contribution.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as strings from 'vs/base/common/strings';
1414
import { AccessibilityVerbositySettingId, AccessibleViewProviderId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
1515
import { AccessibleViewType, IAccessibleContentProvider, IAccessibleViewOptions, IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
1616
import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions';
17-
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
17+
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1818
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1919
import { Disposable, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
2020
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
@@ -27,6 +27,62 @@ import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/co
2727
import { COMMENTS_VIEW_ID } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer';
2828
import { CommentThreadState } from 'vs/editor/common/languages';
2929
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
30+
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
31+
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
32+
import { MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
33+
import { CONTEXT_KEY_HAS_COMMENTS, CONTEXT_KEY_SOME_COMMENTS_EXPANDED, CommentsPanel } from 'vs/workbench/contrib/comments/browser/commentsView';
34+
import { ViewAction } from 'vs/workbench/browser/parts/views/viewPane';
35+
import { Codicon } from 'vs/base/common/codicons';
36+
37+
CommandsRegistry.registerCommand({
38+
id: 'workbench.action.focusCommentsPanel',
39+
handler: async (accessor) => {
40+
const viewsService = accessor.get(IViewsService);
41+
viewsService.openView(COMMENTS_VIEW_ID, true);
42+
}
43+
});
44+
45+
registerAction2(class Collapse extends ViewAction<CommentsPanel> {
46+
constructor() {
47+
super({
48+
viewId: COMMENTS_VIEW_ID,
49+
id: 'comments.collapse',
50+
title: nls.localize('collapseAll', "Collapse All"),
51+
f1: false,
52+
icon: Codicon.collapseAll,
53+
menu: {
54+
id: MenuId.ViewTitle,
55+
group: 'navigation',
56+
when: ContextKeyExpr.and(ContextKeyExpr.and(ContextKeyExpr.equals('view', COMMENTS_VIEW_ID), CONTEXT_KEY_HAS_COMMENTS), CONTEXT_KEY_SOME_COMMENTS_EXPANDED),
57+
order: 100
58+
}
59+
});
60+
}
61+
runInView(_accessor: ServicesAccessor, view: CommentsPanel) {
62+
view.collapseAll();
63+
}
64+
});
65+
66+
registerAction2(class Expand extends ViewAction<CommentsPanel> {
67+
constructor() {
68+
super({
69+
viewId: COMMENTS_VIEW_ID,
70+
id: 'comments.expand',
71+
title: nls.localize('expandAll', "Expand All"),
72+
f1: false,
73+
icon: Codicon.expandAll,
74+
menu: {
75+
id: MenuId.ViewTitle,
76+
group: 'navigation',
77+
when: ContextKeyExpr.and(ContextKeyExpr.and(ContextKeyExpr.equals('view', COMMENTS_VIEW_ID), CONTEXT_KEY_HAS_COMMENTS), ContextKeyExpr.not(CONTEXT_KEY_SOME_COMMENTS_EXPANDED.key)),
78+
order: 100
79+
}
80+
});
81+
}
82+
runInView(_accessor: ServicesAccessor, view: CommentsPanel) {
83+
view.expandAll();
84+
}
85+
});
3086

3187
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
3288
id: 'comments',

src/vs/workbench/contrib/comments/browser/commentsView.ts

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,23 @@ import * as nls from 'vs/nls';
88
import * as dom from 'vs/base/browser/dom';
99
import { basename } from 'vs/base/common/resources';
1010
import { isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
11-
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
11+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1212
import { IThemeService } from 'vs/platform/theme/common/themeService';
1313
import { CommentNode, ResourceWithCommentThreads, ICommentThreadChangedEvent } from 'vs/workbench/contrib/comments/common/commentModel';
1414
import { IWorkspaceCommentThreadsEvent, ICommentService } from 'vs/workbench/contrib/comments/browser/commentService';
1515
import { IEditorService, ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
16-
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
1716
import { textLinkForeground, textLinkActiveForeground, focusBorder, textPreformatForeground } from 'vs/platform/theme/common/colorRegistry';
1817
import { ResourceLabels } from 'vs/workbench/browser/labels';
19-
import { CommentsList, COMMENTS_VIEW_ID, COMMENTS_VIEW_TITLE, Filter } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer';
20-
import { IViewPaneOptions, ViewAction, FilterViewPane } from 'vs/workbench/browser/parts/views/viewPane';
18+
import { CommentsList, COMMENTS_VIEW_TITLE, Filter } from 'vs/workbench/contrib/comments/browser/commentsTreeViewer';
19+
import { IViewPaneOptions, FilterViewPane } from 'vs/workbench/browser/parts/views/viewPane';
2120
import { IViewDescriptorService } from 'vs/workbench/common/views';
22-
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
2321
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
24-
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
22+
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
2523
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2624
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2725
import { IOpenerService } from 'vs/platform/opener/common/opener';
2826
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2927
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
30-
import { MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
31-
import { Codicon } from 'vs/base/common/codicons';
3228
import { IEditor } from 'vs/editor/common/editorCommon';
3329
import { TextModel } from 'vs/editor/common/model/textModel';
3430
import { CommentsViewFilterFocusContextKey, ICommentsView } from 'vs/workbench/contrib/comments/browser/comments';
@@ -44,8 +40,8 @@ import { Range } from 'vs/editor/common/core/range';
4440
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
4541
import { CommentsModel, ICommentsModel } from 'vs/workbench/contrib/comments/browser/commentsModel';
4642

47-
const CONTEXT_KEY_HAS_COMMENTS = new RawContextKey<boolean>('commentsView.hasComments', false);
48-
const CONTEXT_KEY_SOME_COMMENTS_EXPANDED = new RawContextKey<boolean>('commentsView.someCommentsExpanded', false);
43+
export const CONTEXT_KEY_HAS_COMMENTS = new RawContextKey<boolean>('commentsView.hasComments', false);
44+
export const CONTEXT_KEY_SOME_COMMENTS_EXPANDED = new RawContextKey<boolean>('commentsView.someCommentsExpanded', false);
4945
const VIEW_STORAGE_ID = 'commentsViewState';
5046

5147
function createResourceCommentsIterator(model: ICommentsModel): Iterable<ITreeElement<ResourceWithCommentThreads | CommentNode>> {
@@ -505,53 +501,3 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
505501
return false;
506502
}
507503
}
508-
509-
CommandsRegistry.registerCommand({
510-
id: 'workbench.action.focusCommentsPanel',
511-
handler: async (accessor) => {
512-
const viewsService = accessor.get(IViewsService);
513-
viewsService.openView(COMMENTS_VIEW_ID, true);
514-
}
515-
});
516-
517-
registerAction2(class Collapse extends ViewAction<CommentsPanel> {
518-
constructor() {
519-
super({
520-
viewId: COMMENTS_VIEW_ID,
521-
id: 'comments.collapse',
522-
title: nls.localize('collapseAll', "Collapse All"),
523-
f1: false,
524-
icon: Codicon.collapseAll,
525-
menu: {
526-
id: MenuId.ViewTitle,
527-
group: 'navigation',
528-
when: ContextKeyExpr.and(ContextKeyExpr.and(ContextKeyExpr.equals('view', COMMENTS_VIEW_ID), CONTEXT_KEY_HAS_COMMENTS), CONTEXT_KEY_SOME_COMMENTS_EXPANDED),
529-
order: 100
530-
}
531-
});
532-
}
533-
runInView(_accessor: ServicesAccessor, view: CommentsPanel) {
534-
view.collapseAll();
535-
}
536-
});
537-
538-
registerAction2(class Expand extends ViewAction<CommentsPanel> {
539-
constructor() {
540-
super({
541-
viewId: COMMENTS_VIEW_ID,
542-
id: 'comments.expand',
543-
title: nls.localize('expandAll', "Expand All"),
544-
f1: false,
545-
icon: Codicon.expandAll,
546-
menu: {
547-
id: MenuId.ViewTitle,
548-
group: 'navigation',
549-
when: ContextKeyExpr.and(ContextKeyExpr.and(ContextKeyExpr.equals('view', COMMENTS_VIEW_ID), CONTEXT_KEY_HAS_COMMENTS), ContextKeyExpr.not(CONTEXT_KEY_SOME_COMMENTS_EXPANDED.key)),
550-
order: 100
551-
}
552-
});
553-
}
554-
runInView(_accessor: ServicesAccessor, view: CommentsPanel) {
555-
view.expandAll();
556-
}
557-
});

0 commit comments

Comments
 (0)