@codingame/monaco-vscode-comments-service-override 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/comments.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
2
  import { ICommentService, CommentService } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentService';
3
- import 'vscode/vscode/vs/workbench/contrib/comments/browser/comments.contribution';
3
+ import './vscode/src/vs/workbench/contrib/comments/browser/comments.contribution.js';
4
4
 
5
5
  function getServiceOverride() {
6
6
  return {
@@ -0,0 +1,11 @@
1
+ function __decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ function __param(paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ }
10
+
11
+ export { __decorate, __param };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-comments-service-override",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,6 +18,6 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@4.1.0"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.1.2"
22
22
  }
23
23
  }
@@ -0,0 +1,233 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
4
+ import './commentsEditorContribution.js';
5
+ import { ICommentService } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentService';
6
+ import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
7
+ import { Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
8
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
9
+ import { Extensions as Extensions$1 } from 'vscode/vscode/vs/workbench/common/contributions';
10
+ import { NumberBadge, IActivityService } from 'vscode/vscode/vs/workbench/services/activity/common/activity';
11
+ import { COMMENTS_VIEW_ID } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentsTreeViewer';
12
+ import { CommentThreadState } from 'vscode/vscode/vs/editor/common/languages';
13
+ import { registerAction2, MenuId, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
14
+ import { CONTEXT_KEY_HAS_COMMENTS, CONTEXT_KEY_SOME_COMMENTS_EXPANDED } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentsView';
15
+ import { ViewAction } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
16
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
17
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
18
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
19
+ import { revealCommentThread } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentsController';
20
+
21
+ registerAction2(class Collapse extends ViewAction {
22
+ constructor() {
23
+ super({
24
+ viewId: COMMENTS_VIEW_ID,
25
+ id: 'comments.collapse',
26
+ title: ( localizeWithPath(
27
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
28
+ 'collapseAll',
29
+ "Collapse All"
30
+ )),
31
+ f1: false,
32
+ icon: Codicon.collapseAll,
33
+ menu: {
34
+ id: MenuId.ViewTitle,
35
+ group: 'navigation',
36
+ when: ( ContextKeyExpr.and(( ContextKeyExpr.and(( ContextKeyExpr.equals('view', COMMENTS_VIEW_ID)), CONTEXT_KEY_HAS_COMMENTS)), CONTEXT_KEY_SOME_COMMENTS_EXPANDED)),
37
+ order: 100
38
+ }
39
+ });
40
+ }
41
+ runInView(_accessor, view) {
42
+ view.collapseAll();
43
+ }
44
+ });
45
+ registerAction2(class Expand extends ViewAction {
46
+ constructor() {
47
+ super({
48
+ viewId: COMMENTS_VIEW_ID,
49
+ id: 'comments.expand',
50
+ title: ( localizeWithPath(
51
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
52
+ 'expandAll',
53
+ "Expand All"
54
+ )),
55
+ f1: false,
56
+ icon: Codicon.expandAll,
57
+ menu: {
58
+ id: MenuId.ViewTitle,
59
+ group: 'navigation',
60
+ when: ( ContextKeyExpr.and(( ContextKeyExpr.and(( ContextKeyExpr.equals('view', COMMENTS_VIEW_ID)), CONTEXT_KEY_HAS_COMMENTS)), ContextKeyExpr.not(CONTEXT_KEY_SOME_COMMENTS_EXPANDED.key))),
61
+ order: 100
62
+ }
63
+ });
64
+ }
65
+ runInView(_accessor, view) {
66
+ view.expandAll();
67
+ }
68
+ });
69
+ registerAction2(class Reply extends Action2 {
70
+ constructor() {
71
+ super({
72
+ id: 'comments.reply',
73
+ title: ( localizeWithPath(
74
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
75
+ 'reply',
76
+ "Reply"
77
+ )),
78
+ icon: Codicon.reply,
79
+ menu: {
80
+ id: MenuId.CommentsViewThreadActions,
81
+ order: 100,
82
+ when: ( ContextKeyExpr.equals('canReply', true))
83
+ },
84
+ });
85
+ }
86
+ run(accessor, marshalledCommentThread) {
87
+ const commentService = accessor.get(ICommentService);
88
+ const editorService = accessor.get(IEditorService);
89
+ const uriIdentityService = accessor.get(IUriIdentityService);
90
+ revealCommentThread(commentService, editorService, uriIdentityService, marshalledCommentThread.thread, marshalledCommentThread.thread.comments[marshalledCommentThread.thread.comments.length - 1], true);
91
+ }
92
+ });
93
+ ( Registry.as(Extensions.Configuration)).registerConfiguration({
94
+ id: 'comments',
95
+ order: 20,
96
+ title: ( localizeWithPath(
97
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
98
+ 'commentsConfigurationTitle',
99
+ "Comments"
100
+ )),
101
+ type: 'object',
102
+ properties: {
103
+ 'comments.openPanel': {
104
+ enum: ['neverOpen', 'openOnSessionStart', 'openOnSessionStartWithComments'],
105
+ default: 'openOnSessionStartWithComments',
106
+ description: ( localizeWithPath(
107
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
108
+ 'openComments',
109
+ "Controls when the comments panel should open."
110
+ )),
111
+ restricted: false,
112
+ markdownDeprecationMessage: ( localizeWithPath(
113
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
114
+ 'comments.openPanel.deprecated',
115
+ "This setting is deprecated in favor of `comments.openView`."
116
+ ))
117
+ },
118
+ 'comments.openView': {
119
+ enum: ['never', 'file', 'firstFile', 'firstFileUnresolved'],
120
+ enumDescriptions: [( localizeWithPath(
121
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
122
+ 'comments.openView.never',
123
+ "The comments view will never be opened."
124
+ )), ( localizeWithPath(
125
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
126
+ 'comments.openView.file',
127
+ "The comments view will open when a file with comments is active."
128
+ )), ( localizeWithPath(
129
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
130
+ 'comments.openView.firstFile',
131
+ "If the comments view has not been opened yet during this session it will open the first time during a session that a file with comments is active."
132
+ )), ( localizeWithPath(
133
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
134
+ 'comments.openView.firstFileUnresolved',
135
+ "If the comments view has not been opened yet during this session and the comment is not resolved, it will open the first time during a session that a file with comments is active."
136
+ ))],
137
+ default: 'firstFile',
138
+ description: ( localizeWithPath(
139
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
140
+ 'comments.openView',
141
+ "Controls when the comments view should open."
142
+ )),
143
+ restricted: false
144
+ },
145
+ 'comments.useRelativeTime': {
146
+ type: 'boolean',
147
+ default: true,
148
+ description: ( localizeWithPath(
149
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
150
+ 'useRelativeTime',
151
+ "Determines if relative time will be used in comment timestamps (ex. '1 day ago')."
152
+ ))
153
+ },
154
+ 'comments.visible': {
155
+ type: 'boolean',
156
+ default: true,
157
+ description: ( localizeWithPath(
158
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
159
+ 'comments.visible',
160
+ "Controls the visibility of the comments bar and comment threads in editors that have commenting ranges and comments. Comments are still accessible via the Comments view and will cause commenting to be toggled on in the same way running the command \"Comments: Toggle Editor Commenting\" toggles comments."
161
+ ))
162
+ },
163
+ 'comments.maxHeight': {
164
+ type: 'boolean',
165
+ default: true,
166
+ description: ( localizeWithPath(
167
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
168
+ 'comments.maxHeight',
169
+ "Controls whether the comments widget scrolls or expands."
170
+ ))
171
+ },
172
+ 'comments.collapseOnResolve': {
173
+ type: 'boolean',
174
+ default: true,
175
+ description: ( localizeWithPath(
176
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
177
+ 'collapseOnResolve',
178
+ "Controls whether the comment thread should collapse when the thread is resolved."
179
+ ))
180
+ }
181
+ }
182
+ });
183
+ let UnresolvedCommentsBadge = class UnresolvedCommentsBadge extends Disposable {
184
+ constructor(_commentService, activityService) {
185
+ super();
186
+ this._commentService = _commentService;
187
+ this.activityService = activityService;
188
+ this.activity = this._register(( new MutableDisposable()));
189
+ this.totalUnresolved = 0;
190
+ this._register(this._commentService.onDidSetAllCommentThreads(this.onAllCommentsChanged, this));
191
+ this._register(this._commentService.onDidUpdateCommentThreads(this.onCommentsUpdated, this));
192
+ }
193
+ onAllCommentsChanged(e) {
194
+ let unresolved = 0;
195
+ for (const thread of e.commentThreads) {
196
+ if (thread.state === CommentThreadState.Unresolved) {
197
+ unresolved++;
198
+ }
199
+ }
200
+ this.updateBadge(unresolved);
201
+ }
202
+ onCommentsUpdated() {
203
+ let unresolved = 0;
204
+ for (const resource of this._commentService.commentsModel.resourceCommentThreads) {
205
+ for (const thread of resource.commentThreads) {
206
+ if (thread.threadState === CommentThreadState.Unresolved) {
207
+ unresolved++;
208
+ }
209
+ }
210
+ }
211
+ this.updateBadge(unresolved);
212
+ }
213
+ updateBadge(unresolved) {
214
+ if (unresolved === this.totalUnresolved) {
215
+ return;
216
+ }
217
+ this.totalUnresolved = unresolved;
218
+ const message = ( localizeWithPath(
219
+ 'vs/workbench/contrib/comments/browser/comments.contribution',
220
+ 'totalUnresolvedComments',
221
+ '{0} Unresolved Comments',
222
+ this.totalUnresolved
223
+ ));
224
+ this.activity.value = this.activityService.showViewActivity(COMMENTS_VIEW_ID, { badge: ( new NumberBadge(this.totalUnresolved, () => message)) });
225
+ }
226
+ };
227
+ UnresolvedCommentsBadge = ( __decorate([
228
+ ( __param(0, ICommentService)),
229
+ ( __param(1, IActivityService))
230
+ ], UnresolvedCommentsBadge));
231
+ ( Registry.as(Extensions$1.Workbench)).registerWorkbenchContribution(UnresolvedCommentsBadge, 4 );
232
+
233
+ export { UnresolvedCommentsBadge };
@@ -0,0 +1,284 @@
1
+ import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
2
+ import 'vscode/vscode/vs/workbench/contrib/comments/browser/media/review.css';
3
+ import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
4
+ import { registerEditorContribution } from 'vscode/vscode/vs/editor/browser/editorExtensions';
5
+ import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
6
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
7
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
8
+ import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
9
+ import { ICommentService } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentService';
10
+ import { ctxCommentEditorFocused, SimpleCommentEditor } from 'vscode/vscode/vs/workbench/contrib/comments/browser/simpleCommentEditor';
11
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
12
+ import { MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
13
+ import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
14
+ import { ID, CommentController } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentsController';
15
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
16
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
17
+ import { CommentContextKeys } from 'vscode/vscode/vs/workbench/contrib/comments/common/commentContextKeys';
18
+ import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
19
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
20
+ import { accessibilityHelpIsShown, accessibleViewCurrentProviderId } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
21
+
22
+ registerEditorContribution(ID, CommentController, 1 );
23
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
24
+ id: "editor.action.nextCommentThreadAction" ,
25
+ handler: async (accessor, args) => {
26
+ const activeEditor = getActiveEditor(accessor);
27
+ if (!activeEditor) {
28
+ return Promise.resolve();
29
+ }
30
+ const controller = CommentController.get(activeEditor);
31
+ if (!controller) {
32
+ return Promise.resolve();
33
+ }
34
+ controller.nextCommentThread();
35
+ },
36
+ weight: 100 ,
37
+ primary: 512 | 67 ,
38
+ });
39
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
40
+ id: "editor.action.previousCommentThreadAction" ,
41
+ handler: async (accessor, args) => {
42
+ const activeEditor = getActiveEditor(accessor);
43
+ if (!activeEditor) {
44
+ return Promise.resolve();
45
+ }
46
+ const controller = CommentController.get(activeEditor);
47
+ if (!controller) {
48
+ return Promise.resolve();
49
+ }
50
+ controller.previousCommentThread();
51
+ },
52
+ weight: 100 ,
53
+ primary: 1024 | 512 | 67
54
+ });
55
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
56
+ id: "editor.action.nextCommentingRange" ,
57
+ handler: async (accessor, args) => {
58
+ const activeEditor = getActiveEditor(accessor);
59
+ if (!activeEditor) {
60
+ return Promise.resolve();
61
+ }
62
+ const controller = CommentController.get(activeEditor);
63
+ if (!controller) {
64
+ return Promise.resolve();
65
+ }
66
+ controller.nextCommentingRange();
67
+ },
68
+ when: ( ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ( ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ( ContextKeyExpr.and(accessibilityHelpIsShown, ( accessibleViewCurrentProviderId.isEqualTo("comments" )))))))),
69
+ primary: KeyChord(2048 | 41 , 2048 | 512 | 18 ),
70
+ weight: 100
71
+ });
72
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
73
+ command: {
74
+ id: "editor.action.nextCommentingRange" ,
75
+ title: ( localizeWithPath(
76
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
77
+ 'comments.nextCommentingRange',
78
+ "Go to Next Commenting Range"
79
+ )),
80
+ category: 'Comments',
81
+ },
82
+ when: CommentContextKeys.activeEditorHasCommentingRange
83
+ });
84
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
85
+ id: "editor.action.previousCommentingRange" ,
86
+ handler: async (accessor, args) => {
87
+ const activeEditor = getActiveEditor(accessor);
88
+ if (!activeEditor) {
89
+ return Promise.resolve();
90
+ }
91
+ const controller = CommentController.get(activeEditor);
92
+ if (!controller) {
93
+ return Promise.resolve();
94
+ }
95
+ controller.previousCommentingRange();
96
+ },
97
+ when: ( ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ( ContextKeyExpr.or(EditorContextKeys.focus, CommentContextKeys.commentFocused, ( ContextKeyExpr.and(accessibilityHelpIsShown, ( accessibleViewCurrentProviderId.isEqualTo("comments" )))))))),
98
+ primary: KeyChord(2048 | 41 , 2048 | 512 | 16 ),
99
+ weight: 100
100
+ });
101
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
102
+ command: {
103
+ id: "editor.action.previousCommentingRange" ,
104
+ title: ( localizeWithPath(
105
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
106
+ 'comments.previousCommentingRange',
107
+ "Go to Previous Commenting Range"
108
+ )),
109
+ category: 'Comments',
110
+ },
111
+ when: CommentContextKeys.activeEditorHasCommentingRange
112
+ });
113
+ CommandsRegistry.registerCommand({
114
+ id: "workbench.action.toggleCommenting" ,
115
+ handler: (accessor) => {
116
+ const commentService = accessor.get(ICommentService);
117
+ const enable = commentService.isCommentingEnabled;
118
+ commentService.enableCommenting(!enable);
119
+ }
120
+ });
121
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
122
+ command: {
123
+ id: "workbench.action.toggleCommenting" ,
124
+ title: ( localizeWithPath(
125
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
126
+ 'comments.toggleCommenting',
127
+ "Toggle Editor Commenting"
128
+ )),
129
+ category: 'Comments',
130
+ },
131
+ when: CommentContextKeys.WorkspaceHasCommenting
132
+ });
133
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
134
+ id: "workbench.action.addComment" ,
135
+ handler: async (accessor, args) => {
136
+ const activeEditor = getActiveEditor(accessor);
137
+ if (!activeEditor) {
138
+ return Promise.resolve();
139
+ }
140
+ const controller = CommentController.get(activeEditor);
141
+ if (!controller) {
142
+ return Promise.resolve();
143
+ }
144
+ const position = args?.range ? ( new Range(
145
+ args.range.startLineNumber,
146
+ args.range.startLineNumber,
147
+ args.range.endLineNumber,
148
+ args.range.endColumn
149
+ ))
150
+ : (args?.fileComment ? undefined : activeEditor.getSelection());
151
+ const notificationService = accessor.get(INotificationService);
152
+ try {
153
+ await controller.addOrToggleCommentAtLine(position, undefined);
154
+ }
155
+ catch (e) {
156
+ notificationService.error(( localizeWithPath(
157
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
158
+ 'comments.addCommand.error',
159
+ "The cursor must be within a commenting range to add a comment"
160
+ )));
161
+ }
162
+ },
163
+ weight: 100 ,
164
+ primary: KeyChord(2048 | 41 , 2048 | 512 | 33 ),
165
+ });
166
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
167
+ command: {
168
+ id: "workbench.action.addComment" ,
169
+ title: ( localizeWithPath(
170
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
171
+ 'comments.addCommand',
172
+ "Add Comment on Current Selection"
173
+ )),
174
+ category: 'Comments'
175
+ },
176
+ when: CommentContextKeys.activeCursorHasCommentingRange
177
+ });
178
+ CommandsRegistry.registerCommand({
179
+ id: "workbench.action.collapseAllComments" ,
180
+ handler: (accessor) => {
181
+ return getActiveController(accessor)?.collapseAll();
182
+ }
183
+ });
184
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
185
+ command: {
186
+ id: "workbench.action.collapseAllComments" ,
187
+ title: ( localizeWithPath(
188
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
189
+ 'comments.collapseAll',
190
+ "Collapse All Comments"
191
+ )),
192
+ category: 'Comments'
193
+ },
194
+ when: CommentContextKeys.WorkspaceHasCommenting
195
+ });
196
+ CommandsRegistry.registerCommand({
197
+ id: "workbench.action.expandAllComments" ,
198
+ handler: (accessor) => {
199
+ return getActiveController(accessor)?.expandAll();
200
+ }
201
+ });
202
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
203
+ command: {
204
+ id: "workbench.action.expandAllComments" ,
205
+ title: ( localizeWithPath(
206
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
207
+ 'comments.expandAll',
208
+ "Expand All Comments"
209
+ )),
210
+ category: 'Comments'
211
+ },
212
+ when: CommentContextKeys.WorkspaceHasCommenting
213
+ });
214
+ CommandsRegistry.registerCommand({
215
+ id: "workbench.action.expandUnresolvedComments" ,
216
+ handler: (accessor) => {
217
+ return getActiveController(accessor)?.expandUnresolved();
218
+ }
219
+ });
220
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
221
+ command: {
222
+ id: "workbench.action.expandUnresolvedComments" ,
223
+ title: ( localizeWithPath(
224
+ 'vs/workbench/contrib/comments/browser/commentsEditorContribution',
225
+ 'comments.expandUnresolved',
226
+ "Expand Unresolved Comments"
227
+ )),
228
+ category: 'Comments'
229
+ },
230
+ when: CommentContextKeys.WorkspaceHasCommenting
231
+ });
232
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
233
+ id: "editor.action.submitComment" ,
234
+ weight: 100 ,
235
+ primary: 2048 | 3 ,
236
+ when: ctxCommentEditorFocused,
237
+ handler: (accessor, args) => {
238
+ const activeCodeEditor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
239
+ if (activeCodeEditor instanceof SimpleCommentEditor) {
240
+ activeCodeEditor.getParentThread().submitComment();
241
+ }
242
+ }
243
+ });
244
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
245
+ id: "workbench.action.hideComment" ,
246
+ weight: 100 ,
247
+ primary: 9 ,
248
+ secondary: [1024 | 9 ],
249
+ when: ctxCommentEditorFocused,
250
+ handler: (accessor, args) => {
251
+ const activeCodeEditor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
252
+ if (activeCodeEditor instanceof SimpleCommentEditor) {
253
+ activeCodeEditor.getParentThread().collapse();
254
+ }
255
+ }
256
+ });
257
+ function getActiveEditor(accessor) {
258
+ let activeTextEditorControl = accessor.get(IEditorService).activeTextEditorControl;
259
+ if (isDiffEditor(activeTextEditorControl)) {
260
+ if (activeTextEditorControl.getOriginalEditor().hasTextFocus()) {
261
+ activeTextEditorControl = activeTextEditorControl.getOriginalEditor();
262
+ }
263
+ else {
264
+ activeTextEditorControl = activeTextEditorControl.getModifiedEditor();
265
+ }
266
+ }
267
+ if (!isCodeEditor(activeTextEditorControl) || !activeTextEditorControl.hasModel()) {
268
+ return null;
269
+ }
270
+ return activeTextEditorControl;
271
+ }
272
+ function getActiveController(accessor) {
273
+ const activeEditor = getActiveEditor(accessor);
274
+ if (!activeEditor) {
275
+ return undefined;
276
+ }
277
+ const controller = CommentController.get(activeEditor);
278
+ if (!controller) {
279
+ return undefined;
280
+ }
281
+ return controller;
282
+ }
283
+
284
+ export { getActiveEditor };