@codingame/monaco-vscode-comments-service-override 2.2.0-next.1 → 2.2.0-next.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-comments-service-override",
|
|
3
|
-
"version": "2.2.0-next.
|
|
3
|
+
"version": "2.2.0-next.2",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@2.2.0-next.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@2.2.0-next.2",
|
|
22
22
|
"vscode-marked": "npm:marked@=3.0.2"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
3
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
4
|
+
import './commentsEditorContribution.js';
|
|
4
5
|
import { ICommentService } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentService';
|
|
5
6
|
import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
6
7
|
import { Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
@@ -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 };
|