@codingame/monaco-vscode-extensions-service-override 2.1.4 → 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/extensions.js +3 -0
- package/package.json +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +2 -2
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +1 -1
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +1 -1
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/vscode/src/vs/platform/log/browser/log.js +0 -26
- package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +0 -92
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +0 -109
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +0 -397
- package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +0 -5
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +0 -1279
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +0 -19
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +0 -125
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +0 -344
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +0 -453
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +0 -178
- package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +0 -36
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +0 -180
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +0 -5
|
@@ -1,1279 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { Action } from 'vscode/vscode/vs/base/common/actions';
|
|
3
|
-
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
4
|
-
import { findFirstIdxMonotonousOrArrLen } from 'vscode/vscode/vs/base/common/arraysFind';
|
|
5
|
-
import { createCancelablePromise, Delayer } from 'vscode/vscode/vs/base/common/async';
|
|
6
|
-
import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
7
|
-
import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
-
import 'vscode/vscode/vs/workbench/contrib/comments/browser/media/review.css';
|
|
9
|
-
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
10
|
-
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
11
|
-
import { EditorType } from 'vscode/vscode/vs/editor/common/editorCommon';
|
|
12
|
-
import { ModelDecorationOptions } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
13
|
-
import { CommentThreadState } from 'vscode/vscode/vs/editor/common/languages';
|
|
14
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
15
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
16
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
17
|
-
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
18
|
-
import { CommentGlyphWidget } from './commentGlyphWidget.js';
|
|
19
|
-
import { ICommentService } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentService';
|
|
20
|
-
import { ReviewZoneWidget, parseMouseDownInfoFromEvent, isMouseUpEventDragFromMouseDown } from './commentThreadZoneWidget.js';
|
|
21
|
-
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
22
|
-
import { EmbeddedCodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/embeddedCodeEditorWidget';
|
|
23
|
-
import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
|
|
24
|
-
import { COMMENTS_VIEW_ID } from './commentsTreeViewer.js';
|
|
25
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
26
|
-
import { COMMENTS_SECTION } from 'vscode/vscode/vs/workbench/contrib/comments/common/commentsConfiguration';
|
|
27
|
-
import { COMMENTEDITOR_DECORATION_KEY } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentReply';
|
|
28
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
29
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
30
|
-
import { CommentThreadRangeDecorator } from './commentThreadRangeDecorator.js';
|
|
31
|
-
import { status } from 'vscode/vscode/vs/base/browser/ui/aria/aria';
|
|
32
|
-
import { CommentContextKeys } from 'vscode/vscode/vs/workbench/contrib/comments/common/commentContextKeys';
|
|
33
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
34
|
-
import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
|
|
35
|
-
|
|
36
|
-
const ID = 'editor.contrib.review';
|
|
37
|
-
class CommentingRangeDecoration {
|
|
38
|
-
get id() {
|
|
39
|
-
return this._decorationId;
|
|
40
|
-
}
|
|
41
|
-
set id(id) {
|
|
42
|
-
this._decorationId = id;
|
|
43
|
-
}
|
|
44
|
-
get range() {
|
|
45
|
-
return {
|
|
46
|
-
startLineNumber: this._startLineNumber, startColumn: 1,
|
|
47
|
-
endLineNumber: this._endLineNumber, endColumn: 1
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
constructor(_editor, _ownerId, _extensionId, _label, _range, options, commentingRangesInfo, isHover = false) {
|
|
51
|
-
this._editor = _editor;
|
|
52
|
-
this._ownerId = _ownerId;
|
|
53
|
-
this._extensionId = _extensionId;
|
|
54
|
-
this._label = _label;
|
|
55
|
-
this._range = _range;
|
|
56
|
-
this.options = options;
|
|
57
|
-
this.commentingRangesInfo = commentingRangesInfo;
|
|
58
|
-
this.isHover = isHover;
|
|
59
|
-
this._startLineNumber = _range.startLineNumber;
|
|
60
|
-
this._endLineNumber = _range.endLineNumber;
|
|
61
|
-
}
|
|
62
|
-
getCommentAction() {
|
|
63
|
-
return {
|
|
64
|
-
extensionId: this._extensionId,
|
|
65
|
-
label: this._label,
|
|
66
|
-
ownerId: this._ownerId,
|
|
67
|
-
commentingRangesInfo: this.commentingRangesInfo
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
getOriginalRange() {
|
|
71
|
-
return this._range;
|
|
72
|
-
}
|
|
73
|
-
getActiveRange() {
|
|
74
|
-
return this.id ? this._editor.getModel().getDecorationRange(this.id) : undefined;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
class CommentingRangeDecorator {
|
|
78
|
-
static { this.description = 'commenting-range-decorator'; }
|
|
79
|
-
constructor() {
|
|
80
|
-
this.commentingRangeDecorations = [];
|
|
81
|
-
this.decorationIds = [];
|
|
82
|
-
this._lastHover = -1;
|
|
83
|
-
this._onDidChangeDecorationsCount = ( new Emitter());
|
|
84
|
-
this.onDidChangeDecorationsCount = this._onDidChangeDecorationsCount.event;
|
|
85
|
-
const decorationOptions = {
|
|
86
|
-
description: CommentingRangeDecorator.description,
|
|
87
|
-
isWholeLine: true,
|
|
88
|
-
linesDecorationsClassName: 'comment-range-glyph comment-diff-added'
|
|
89
|
-
};
|
|
90
|
-
this.decorationOptions = ModelDecorationOptions.createDynamic(decorationOptions);
|
|
91
|
-
const hoverDecorationOptions = {
|
|
92
|
-
description: CommentingRangeDecorator.description,
|
|
93
|
-
isWholeLine: true,
|
|
94
|
-
linesDecorationsClassName: `comment-range-glyph line-hover`
|
|
95
|
-
};
|
|
96
|
-
this.hoverDecorationOptions = ModelDecorationOptions.createDynamic(hoverDecorationOptions);
|
|
97
|
-
const multilineDecorationOptions = {
|
|
98
|
-
description: CommentingRangeDecorator.description,
|
|
99
|
-
isWholeLine: true,
|
|
100
|
-
linesDecorationsClassName: `comment-range-glyph multiline-add`
|
|
101
|
-
};
|
|
102
|
-
this.multilineDecorationOptions = ModelDecorationOptions.createDynamic(multilineDecorationOptions);
|
|
103
|
-
}
|
|
104
|
-
updateHover(hoverLine) {
|
|
105
|
-
if (this._editor && this._infos && (hoverLine !== this._lastHover)) {
|
|
106
|
-
this._doUpdate(this._editor, this._infos, hoverLine);
|
|
107
|
-
}
|
|
108
|
-
this._lastHover = hoverLine ?? -1;
|
|
109
|
-
}
|
|
110
|
-
updateSelection(cursorLine, range = ( new Range(0, 0, 0, 0))) {
|
|
111
|
-
this._lastSelection = range.isEmpty() ? undefined : range;
|
|
112
|
-
this._lastSelectionCursor = range.isEmpty() ? undefined : cursorLine;
|
|
113
|
-
if (this._editor && this._infos) {
|
|
114
|
-
this._doUpdate(this._editor, this._infos, cursorLine, range);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
update(editor, commentInfos, cursorLine, range) {
|
|
118
|
-
if (editor) {
|
|
119
|
-
this._editor = editor;
|
|
120
|
-
this._infos = commentInfos;
|
|
121
|
-
this._doUpdate(editor, commentInfos, cursorLine, range);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
_lineHasThread(editor, lineRange) {
|
|
125
|
-
return editor.getDecorationsInRange(lineRange)?.find(decoration => decoration.options.description === CommentGlyphWidget.description);
|
|
126
|
-
}
|
|
127
|
-
_doUpdate(editor, commentInfos, emphasisLine = -1, selectionRange = this._lastSelection) {
|
|
128
|
-
const model = editor.getModel();
|
|
129
|
-
if (!model) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
emphasisLine = this._lastSelectionCursor ?? emphasisLine;
|
|
133
|
-
const commentingRangeDecorations = [];
|
|
134
|
-
for (const info of commentInfos) {
|
|
135
|
-
info.commentingRanges.ranges.forEach(range => {
|
|
136
|
-
const rangeObject = ( new Range(
|
|
137
|
-
range.startLineNumber,
|
|
138
|
-
range.startColumn,
|
|
139
|
-
range.endLineNumber,
|
|
140
|
-
range.endColumn
|
|
141
|
-
));
|
|
142
|
-
let intersectingSelectionRange = selectionRange ? rangeObject.intersectRanges(selectionRange) : undefined;
|
|
143
|
-
if ((selectionRange && (emphasisLine >= 0) && intersectingSelectionRange)
|
|
144
|
-
&& !((intersectingSelectionRange.startLineNumber === intersectingSelectionRange.endLineNumber)
|
|
145
|
-
&& (emphasisLine === intersectingSelectionRange.startLineNumber))) {
|
|
146
|
-
let intersectingEmphasisRange;
|
|
147
|
-
if (emphasisLine <= intersectingSelectionRange.startLineNumber) {
|
|
148
|
-
intersectingEmphasisRange = intersectingSelectionRange.collapseToStart();
|
|
149
|
-
intersectingSelectionRange = ( new Range(
|
|
150
|
-
intersectingSelectionRange.startLineNumber + 1,
|
|
151
|
-
1,
|
|
152
|
-
intersectingSelectionRange.endLineNumber,
|
|
153
|
-
1
|
|
154
|
-
));
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
intersectingEmphasisRange = ( new Range(
|
|
158
|
-
intersectingSelectionRange.endLineNumber,
|
|
159
|
-
1,
|
|
160
|
-
intersectingSelectionRange.endLineNumber,
|
|
161
|
-
1
|
|
162
|
-
));
|
|
163
|
-
intersectingSelectionRange = ( new Range(
|
|
164
|
-
intersectingSelectionRange.startLineNumber,
|
|
165
|
-
1,
|
|
166
|
-
intersectingSelectionRange.endLineNumber - 1,
|
|
167
|
-
1
|
|
168
|
-
));
|
|
169
|
-
}
|
|
170
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
171
|
-
editor,
|
|
172
|
-
info.owner,
|
|
173
|
-
info.extensionId,
|
|
174
|
-
info.label,
|
|
175
|
-
intersectingSelectionRange,
|
|
176
|
-
this.multilineDecorationOptions,
|
|
177
|
-
info.commentingRanges,
|
|
178
|
-
true
|
|
179
|
-
)));
|
|
180
|
-
if (!this._lineHasThread(editor, intersectingEmphasisRange)) {
|
|
181
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
182
|
-
editor,
|
|
183
|
-
info.owner,
|
|
184
|
-
info.extensionId,
|
|
185
|
-
info.label,
|
|
186
|
-
intersectingEmphasisRange,
|
|
187
|
-
this.hoverDecorationOptions,
|
|
188
|
-
info.commentingRanges,
|
|
189
|
-
true
|
|
190
|
-
)));
|
|
191
|
-
}
|
|
192
|
-
const beforeRangeEndLine = Math.min(intersectingEmphasisRange.startLineNumber, intersectingSelectionRange.startLineNumber) - 1;
|
|
193
|
-
const hasBeforeRange = rangeObject.startLineNumber <= beforeRangeEndLine;
|
|
194
|
-
const afterRangeStartLine = Math.max(intersectingEmphasisRange.endLineNumber, intersectingSelectionRange.endLineNumber) + 1;
|
|
195
|
-
const hasAfterRange = rangeObject.endLineNumber >= afterRangeStartLine;
|
|
196
|
-
if (hasBeforeRange) {
|
|
197
|
-
const beforeRange = ( new Range(range.startLineNumber, 1, beforeRangeEndLine, 1));
|
|
198
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
199
|
-
editor,
|
|
200
|
-
info.owner,
|
|
201
|
-
info.extensionId,
|
|
202
|
-
info.label,
|
|
203
|
-
beforeRange,
|
|
204
|
-
this.decorationOptions,
|
|
205
|
-
info.commentingRanges,
|
|
206
|
-
true
|
|
207
|
-
)));
|
|
208
|
-
}
|
|
209
|
-
if (hasAfterRange) {
|
|
210
|
-
const afterRange = ( new Range(afterRangeStartLine, 1, range.endLineNumber, 1));
|
|
211
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
212
|
-
editor,
|
|
213
|
-
info.owner,
|
|
214
|
-
info.extensionId,
|
|
215
|
-
info.label,
|
|
216
|
-
afterRange,
|
|
217
|
-
this.decorationOptions,
|
|
218
|
-
info.commentingRanges,
|
|
219
|
-
true
|
|
220
|
-
)));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
else if ((rangeObject.startLineNumber <= emphasisLine) && (emphasisLine <= rangeObject.endLineNumber)) {
|
|
224
|
-
if (rangeObject.startLineNumber < emphasisLine) {
|
|
225
|
-
const beforeRange = ( new Range(range.startLineNumber, 1, emphasisLine - 1, 1));
|
|
226
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
227
|
-
editor,
|
|
228
|
-
info.owner,
|
|
229
|
-
info.extensionId,
|
|
230
|
-
info.label,
|
|
231
|
-
beforeRange,
|
|
232
|
-
this.decorationOptions,
|
|
233
|
-
info.commentingRanges,
|
|
234
|
-
true
|
|
235
|
-
)));
|
|
236
|
-
}
|
|
237
|
-
const emphasisRange = ( new Range(emphasisLine, 1, emphasisLine, 1));
|
|
238
|
-
if (!this._lineHasThread(editor, emphasisRange)) {
|
|
239
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
240
|
-
editor,
|
|
241
|
-
info.owner,
|
|
242
|
-
info.extensionId,
|
|
243
|
-
info.label,
|
|
244
|
-
emphasisRange,
|
|
245
|
-
this.hoverDecorationOptions,
|
|
246
|
-
info.commentingRanges,
|
|
247
|
-
true
|
|
248
|
-
)));
|
|
249
|
-
}
|
|
250
|
-
if (emphasisLine < rangeObject.endLineNumber) {
|
|
251
|
-
const afterRange = ( new Range(emphasisLine + 1, 1, range.endLineNumber, 1));
|
|
252
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
253
|
-
editor,
|
|
254
|
-
info.owner,
|
|
255
|
-
info.extensionId,
|
|
256
|
-
info.label,
|
|
257
|
-
afterRange,
|
|
258
|
-
this.decorationOptions,
|
|
259
|
-
info.commentingRanges,
|
|
260
|
-
true
|
|
261
|
-
)));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
commentingRangeDecorations.push(( new CommentingRangeDecoration(
|
|
266
|
-
editor,
|
|
267
|
-
info.owner,
|
|
268
|
-
info.extensionId,
|
|
269
|
-
info.label,
|
|
270
|
-
range,
|
|
271
|
-
this.decorationOptions,
|
|
272
|
-
info.commentingRanges
|
|
273
|
-
)));
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
editor.changeDecorations((accessor) => {
|
|
278
|
-
this.decorationIds = accessor.deltaDecorations(this.decorationIds, commentingRangeDecorations);
|
|
279
|
-
commentingRangeDecorations.forEach((decoration, index) => decoration.id = this.decorationIds[index]);
|
|
280
|
-
});
|
|
281
|
-
const rangesDifference = this.commentingRangeDecorations.length - commentingRangeDecorations.length;
|
|
282
|
-
this.commentingRangeDecorations = commentingRangeDecorations;
|
|
283
|
-
if (rangesDifference) {
|
|
284
|
-
this._onDidChangeDecorationsCount.fire(this.commentingRangeDecorations.length);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
areRangesIntersectingOrTouchingByLine(a, b) {
|
|
288
|
-
if (a.endLineNumber < (b.startLineNumber - 1)) {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
if ((b.endLineNumber + 1) < a.startLineNumber) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
getMatchedCommentAction(commentRange) {
|
|
297
|
-
if (commentRange === undefined) {
|
|
298
|
-
const foundInfos = this._infos?.filter(info => info.commentingRanges.fileComments);
|
|
299
|
-
if (foundInfos) {
|
|
300
|
-
return ( foundInfos.map(foundInfo => {
|
|
301
|
-
return {
|
|
302
|
-
action: {
|
|
303
|
-
ownerId: foundInfo.owner,
|
|
304
|
-
extensionId: foundInfo.extensionId,
|
|
305
|
-
label: foundInfo.label,
|
|
306
|
-
commentingRangesInfo: foundInfo.commentingRanges
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
}));
|
|
310
|
-
}
|
|
311
|
-
return [];
|
|
312
|
-
}
|
|
313
|
-
const foundHoverActions = ( new Map());
|
|
314
|
-
for (const decoration of this.commentingRangeDecorations) {
|
|
315
|
-
const range = decoration.getActiveRange();
|
|
316
|
-
if (range && this.areRangesIntersectingOrTouchingByLine(range, commentRange)) {
|
|
317
|
-
const action = decoration.getCommentAction();
|
|
318
|
-
const alreadyFoundInfo = foundHoverActions.get(action.ownerId);
|
|
319
|
-
if (alreadyFoundInfo?.action.commentingRangesInfo === action.commentingRangesInfo) {
|
|
320
|
-
const newRange = ( new Range(
|
|
321
|
-
range.startLineNumber < alreadyFoundInfo.range.startLineNumber ? range.startLineNumber : alreadyFoundInfo.range.startLineNumber,
|
|
322
|
-
range.startColumn < alreadyFoundInfo.range.startColumn ? range.startColumn : alreadyFoundInfo.range.startColumn,
|
|
323
|
-
range.endLineNumber > alreadyFoundInfo.range.endLineNumber ? range.endLineNumber : alreadyFoundInfo.range.endLineNumber,
|
|
324
|
-
range.endColumn > alreadyFoundInfo.range.endColumn ? range.endColumn : alreadyFoundInfo.range.endColumn
|
|
325
|
-
));
|
|
326
|
-
foundHoverActions.set(action.ownerId, { range: newRange, action });
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
foundHoverActions.set(action.ownerId, { range, action });
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
const seenOwners = ( new Set());
|
|
334
|
-
return Array.from(( foundHoverActions.values())).filter(action => {
|
|
335
|
-
if (( seenOwners.has(action.action.ownerId))) {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
seenOwners.add(action.action.ownerId);
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
getNearestCommentingRange(findPosition, reverse) {
|
|
345
|
-
let findPositionContainedWithin;
|
|
346
|
-
let decorations;
|
|
347
|
-
if (reverse) {
|
|
348
|
-
decorations = [];
|
|
349
|
-
for (let i = this.commentingRangeDecorations.length - 1; i >= 0; i--) {
|
|
350
|
-
decorations.push(this.commentingRangeDecorations[i]);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
decorations = this.commentingRangeDecorations;
|
|
355
|
-
}
|
|
356
|
-
for (const decoration of decorations) {
|
|
357
|
-
const range = decoration.getActiveRange();
|
|
358
|
-
if (!range) {
|
|
359
|
-
continue;
|
|
360
|
-
}
|
|
361
|
-
if (findPositionContainedWithin && this.areRangesIntersectingOrTouchingByLine(range, findPositionContainedWithin)) {
|
|
362
|
-
findPositionContainedWithin = Range.plusRange(findPositionContainedWithin, range);
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
if (range.startLineNumber <= findPosition.lineNumber && findPosition.lineNumber <= range.endLineNumber) {
|
|
366
|
-
findPositionContainedWithin = ( new Range(
|
|
367
|
-
range.startLineNumber,
|
|
368
|
-
range.startColumn,
|
|
369
|
-
range.endLineNumber,
|
|
370
|
-
range.endColumn
|
|
371
|
-
));
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
if (!reverse && range.endLineNumber < findPosition.lineNumber) {
|
|
375
|
-
continue;
|
|
376
|
-
}
|
|
377
|
-
if (reverse && range.startLineNumber > findPosition.lineNumber) {
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
return range;
|
|
381
|
-
}
|
|
382
|
-
return (decorations.length > 0 ? (decorations[0].getActiveRange() ?? undefined) : undefined);
|
|
383
|
-
}
|
|
384
|
-
dispose() {
|
|
385
|
-
this.commentingRangeDecorations = [];
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
let CommentController = class CommentController {
|
|
389
|
-
constructor(editor, commentService, instantiationService, codeEditorService, contextMenuService, quickInputService, viewsService, configurationService, contextKeyService, editorService, keybindingService, accessibilityService) {
|
|
390
|
-
this.commentService = commentService;
|
|
391
|
-
this.instantiationService = instantiationService;
|
|
392
|
-
this.codeEditorService = codeEditorService;
|
|
393
|
-
this.contextMenuService = contextMenuService;
|
|
394
|
-
this.quickInputService = quickInputService;
|
|
395
|
-
this.viewsService = viewsService;
|
|
396
|
-
this.configurationService = configurationService;
|
|
397
|
-
this.editorService = editorService;
|
|
398
|
-
this.keybindingService = keybindingService;
|
|
399
|
-
this.accessibilityService = accessibilityService;
|
|
400
|
-
this.globalToDispose = ( new DisposableStore());
|
|
401
|
-
this.localToDispose = ( new DisposableStore());
|
|
402
|
-
this.mouseDownInfo = null;
|
|
403
|
-
this._commentingRangeSpaceReserved = false;
|
|
404
|
-
this._emptyThreadsToAddQueue = [];
|
|
405
|
-
this._inProcessContinueOnComments = ( new Map());
|
|
406
|
-
this._editorDisposables = [];
|
|
407
|
-
this._hasRespondedToEditorChange = false;
|
|
408
|
-
this._commentInfos = [];
|
|
409
|
-
this._commentWidgets = [];
|
|
410
|
-
this._pendingNewCommentCache = {};
|
|
411
|
-
this._pendingEditsCache = {};
|
|
412
|
-
this._computePromise = null;
|
|
413
|
-
this._activeCursorHasCommentingRange = CommentContextKeys.activeCursorHasCommentingRange.bindTo(contextKeyService);
|
|
414
|
-
this._activeEditorHasCommentingRange = CommentContextKeys.activeEditorHasCommentingRange.bindTo(contextKeyService);
|
|
415
|
-
if (editor instanceof EmbeddedCodeEditorWidget) {
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
this.editor = editor;
|
|
419
|
-
this._commentingRangeDecorator = ( new CommentingRangeDecorator());
|
|
420
|
-
this.globalToDispose.add(this._commentingRangeDecorator.onDidChangeDecorationsCount(count => {
|
|
421
|
-
if (count === 0) {
|
|
422
|
-
this.clearEditorListeners();
|
|
423
|
-
}
|
|
424
|
-
else if (this._editorDisposables.length === 0) {
|
|
425
|
-
this.registerEditorListeners();
|
|
426
|
-
}
|
|
427
|
-
}));
|
|
428
|
-
this.globalToDispose.add(this._commentThreadRangeDecorator = ( new CommentThreadRangeDecorator(this.commentService)));
|
|
429
|
-
this.globalToDispose.add(this.commentService.onDidDeleteDataProvider(ownerId => {
|
|
430
|
-
if (ownerId) {
|
|
431
|
-
delete this._pendingNewCommentCache[ownerId];
|
|
432
|
-
delete this._pendingEditsCache[ownerId];
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
this._pendingNewCommentCache = {};
|
|
436
|
-
this._pendingEditsCache = {};
|
|
437
|
-
}
|
|
438
|
-
this.beginCompute();
|
|
439
|
-
}));
|
|
440
|
-
this.globalToDispose.add(this.commentService.onDidSetDataProvider(_ => this.beginComputeAndHandleEditorChange()));
|
|
441
|
-
this.globalToDispose.add(this.commentService.onDidUpdateCommentingRanges(_ => this.beginComputeAndHandleEditorChange()));
|
|
442
|
-
this.globalToDispose.add(this.commentService.onDidSetResourceCommentInfos(e => {
|
|
443
|
-
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
|
|
444
|
-
if (editorURI && ( editorURI.toString()) === ( e.resource.toString())) {
|
|
445
|
-
this.setComments(e.commentInfos.filter(commentInfo => commentInfo !== null));
|
|
446
|
-
}
|
|
447
|
-
}));
|
|
448
|
-
this.globalToDispose.add(this.commentService.onDidChangeCommentingEnabled(e => {
|
|
449
|
-
if (e) {
|
|
450
|
-
this.registerEditorListeners();
|
|
451
|
-
this.beginCompute();
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
this.tryUpdateReservedSpace();
|
|
455
|
-
this.clearEditorListeners();
|
|
456
|
-
this._commentingRangeDecorator.update(this.editor, []);
|
|
457
|
-
this._commentThreadRangeDecorator.update(this.editor, []);
|
|
458
|
-
dispose(this._commentWidgets);
|
|
459
|
-
this._commentWidgets = [];
|
|
460
|
-
}
|
|
461
|
-
}));
|
|
462
|
-
this.globalToDispose.add(this.editor.onDidChangeModel(_ => this.onModelChanged()));
|
|
463
|
-
this.globalToDispose.add(this.configurationService.onDidChangeConfiguration(e => {
|
|
464
|
-
if (e.affectsConfiguration('diffEditor.renderSideBySide')) {
|
|
465
|
-
this.beginCompute();
|
|
466
|
-
}
|
|
467
|
-
}));
|
|
468
|
-
this.onModelChanged();
|
|
469
|
-
this.codeEditorService.registerDecorationType('comment-controller', COMMENTEDITOR_DECORATION_KEY, {});
|
|
470
|
-
this.globalToDispose.add(this.commentService.registerContinueOnCommentProvider({
|
|
471
|
-
provideContinueOnComments: () => {
|
|
472
|
-
const pendingComments = [];
|
|
473
|
-
if (this._commentWidgets) {
|
|
474
|
-
for (const zone of this._commentWidgets) {
|
|
475
|
-
const zonePendingComments = zone.getPendingComments();
|
|
476
|
-
const pendingNewComment = zonePendingComments.newComment;
|
|
477
|
-
if (!pendingNewComment) {
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
let lastCommentBody;
|
|
481
|
-
if (zone.commentThread.comments && zone.commentThread.comments.length) {
|
|
482
|
-
const lastComment = zone.commentThread.comments[zone.commentThread.comments.length - 1];
|
|
483
|
-
if (typeof lastComment.body === 'string') {
|
|
484
|
-
lastCommentBody = lastComment.body;
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
487
|
-
lastCommentBody = lastComment.body.value;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
if (pendingNewComment !== lastCommentBody) {
|
|
491
|
-
pendingComments.push({
|
|
492
|
-
owner: zone.owner,
|
|
493
|
-
uri: zone.editor.getModel().uri,
|
|
494
|
-
range: zone.commentThread.range,
|
|
495
|
-
body: pendingNewComment,
|
|
496
|
-
isReply: (zone.commentThread.comments !== undefined) && (zone.commentThread.comments.length > 0)
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return pendingComments;
|
|
502
|
-
}
|
|
503
|
-
}));
|
|
504
|
-
}
|
|
505
|
-
registerEditorListeners() {
|
|
506
|
-
this._editorDisposables = [];
|
|
507
|
-
if (!this.editor) {
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
this._editorDisposables.push(this.editor.onMouseMove(e => this.onEditorMouseMove(e)));
|
|
511
|
-
this._editorDisposables.push(this.editor.onMouseLeave(() => this.onEditorMouseLeave()));
|
|
512
|
-
this._editorDisposables.push(this.editor.onDidChangeCursorPosition(e => this.onEditorChangeCursorPosition(e.position)));
|
|
513
|
-
this._editorDisposables.push(this.editor.onDidFocusEditorWidget(() => this.onEditorChangeCursorPosition(this.editor?.getPosition() ?? null)));
|
|
514
|
-
this._editorDisposables.push(this.editor.onDidChangeCursorSelection(e => this.onEditorChangeCursorSelection(e)));
|
|
515
|
-
this._editorDisposables.push(this.editor.onDidBlurEditorWidget(() => this.onEditorChangeCursorSelection()));
|
|
516
|
-
}
|
|
517
|
-
clearEditorListeners() {
|
|
518
|
-
dispose(this._editorDisposables);
|
|
519
|
-
this._editorDisposables = [];
|
|
520
|
-
}
|
|
521
|
-
onEditorMouseLeave() {
|
|
522
|
-
this._commentingRangeDecorator.updateHover();
|
|
523
|
-
}
|
|
524
|
-
onEditorMouseMove(e) {
|
|
525
|
-
const position = e.target.position?.lineNumber;
|
|
526
|
-
if (e.event.leftButton.valueOf() && position && this.mouseDownInfo) {
|
|
527
|
-
this._commentingRangeDecorator.updateSelection(position, ( new Range(this.mouseDownInfo.lineNumber, 1, position, 1)));
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
this._commentingRangeDecorator.updateHover(position);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
onEditorChangeCursorSelection(e) {
|
|
534
|
-
const position = this.editor?.getPosition()?.lineNumber;
|
|
535
|
-
if (position) {
|
|
536
|
-
this._commentingRangeDecorator.updateSelection(position, e?.selection);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
onEditorChangeCursorPosition(e) {
|
|
540
|
-
const decorations = e ? this.editor?.getDecorationsInRange(Range.fromPositions(e, { column: -1, lineNumber: e.lineNumber })) : undefined;
|
|
541
|
-
let hasCommentingRange = false;
|
|
542
|
-
if (decorations) {
|
|
543
|
-
for (const decoration of decorations) {
|
|
544
|
-
if (decoration.options.description === CommentGlyphWidget.description) {
|
|
545
|
-
hasCommentingRange = false;
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
else if (decoration.options.description === CommentingRangeDecorator.description) {
|
|
549
|
-
hasCommentingRange = true;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
this._activeCursorHasCommentingRange.set(hasCommentingRange);
|
|
554
|
-
}
|
|
555
|
-
isEditorInlineOriginal(testEditor) {
|
|
556
|
-
if (this.configurationService.getValue('diffEditor.renderSideBySide')) {
|
|
557
|
-
return false;
|
|
558
|
-
}
|
|
559
|
-
const foundEditor = this.editorService.visibleTextEditorControls.find(editor => {
|
|
560
|
-
if (editor.getEditorType() === EditorType.IDiffEditor) {
|
|
561
|
-
const diffEditor = editor;
|
|
562
|
-
return diffEditor.getOriginalEditor() === testEditor;
|
|
563
|
-
}
|
|
564
|
-
return false;
|
|
565
|
-
});
|
|
566
|
-
return !!foundEditor;
|
|
567
|
-
}
|
|
568
|
-
beginCompute() {
|
|
569
|
-
this._computePromise = createCancelablePromise(token => {
|
|
570
|
-
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
|
|
571
|
-
if (editorURI) {
|
|
572
|
-
return this.commentService.getDocumentComments(editorURI);
|
|
573
|
-
}
|
|
574
|
-
return Promise.resolve([]);
|
|
575
|
-
});
|
|
576
|
-
return this._computePromise.then(commentInfos => {
|
|
577
|
-
this.setComments(coalesce(commentInfos));
|
|
578
|
-
this._computePromise = null;
|
|
579
|
-
}, error => console.log(error));
|
|
580
|
-
}
|
|
581
|
-
beginComputeCommentingRanges() {
|
|
582
|
-
if (this._computeCommentingRangeScheduler) {
|
|
583
|
-
if (this._computeCommentingRangePromise) {
|
|
584
|
-
this._computeCommentingRangePromise.cancel();
|
|
585
|
-
this._computeCommentingRangePromise = null;
|
|
586
|
-
}
|
|
587
|
-
this._computeCommentingRangeScheduler.trigger(() => {
|
|
588
|
-
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
|
|
589
|
-
if (editorURI) {
|
|
590
|
-
return this.commentService.getDocumentComments(editorURI);
|
|
591
|
-
}
|
|
592
|
-
return Promise.resolve([]);
|
|
593
|
-
}).then(commentInfos => {
|
|
594
|
-
if (this.commentService.isCommentingEnabled) {
|
|
595
|
-
const meaningfulCommentInfos = coalesce(commentInfos);
|
|
596
|
-
this._commentingRangeDecorator.update(this.editor, meaningfulCommentInfos, this.editor?.getPosition()?.lineNumber, this.editor?.getSelection() ?? undefined);
|
|
597
|
-
}
|
|
598
|
-
}, (err) => {
|
|
599
|
-
onUnexpectedError(err);
|
|
600
|
-
return null;
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
static get(editor) {
|
|
605
|
-
return editor.getContribution(ID);
|
|
606
|
-
}
|
|
607
|
-
revealCommentThread(threadId, commentUniqueId, fetchOnceIfNotExist, focus) {
|
|
608
|
-
const commentThreadWidget = this._commentWidgets.filter(widget => widget.commentThread.threadId === threadId);
|
|
609
|
-
if (commentThreadWidget.length === 1) {
|
|
610
|
-
commentThreadWidget[0].reveal(commentUniqueId, focus);
|
|
611
|
-
}
|
|
612
|
-
else if (fetchOnceIfNotExist) {
|
|
613
|
-
if (this._computePromise) {
|
|
614
|
-
this._computePromise.then(_ => {
|
|
615
|
-
this.revealCommentThread(threadId, commentUniqueId, false, focus);
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
this.beginCompute().then(_ => {
|
|
620
|
-
this.revealCommentThread(threadId, commentUniqueId, false, focus);
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
collapseAll() {
|
|
626
|
-
for (const widget of this._commentWidgets) {
|
|
627
|
-
widget.collapse();
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
expandAll() {
|
|
631
|
-
for (const widget of this._commentWidgets) {
|
|
632
|
-
widget.expand();
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
expandUnresolved() {
|
|
636
|
-
for (const widget of this._commentWidgets) {
|
|
637
|
-
if (widget.commentThread.state === CommentThreadState.Unresolved) {
|
|
638
|
-
widget.expand();
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
nextCommentThread() {
|
|
643
|
-
this._findNearestCommentThread();
|
|
644
|
-
}
|
|
645
|
-
_findNearestCommentThread(reverse) {
|
|
646
|
-
if (!this._commentWidgets.length || !this.editor?.hasModel()) {
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
const after = this.editor.getSelection().getEndPosition();
|
|
650
|
-
const sortedWidgets = this._commentWidgets.sort((a, b) => {
|
|
651
|
-
if (reverse) {
|
|
652
|
-
const temp = a;
|
|
653
|
-
a = b;
|
|
654
|
-
b = temp;
|
|
655
|
-
}
|
|
656
|
-
if (a.commentThread.range === undefined) {
|
|
657
|
-
return -1;
|
|
658
|
-
}
|
|
659
|
-
if (b.commentThread.range === undefined) {
|
|
660
|
-
return 1;
|
|
661
|
-
}
|
|
662
|
-
if (a.commentThread.range.startLineNumber < b.commentThread.range.startLineNumber) {
|
|
663
|
-
return -1;
|
|
664
|
-
}
|
|
665
|
-
if (a.commentThread.range.startLineNumber > b.commentThread.range.startLineNumber) {
|
|
666
|
-
return 1;
|
|
667
|
-
}
|
|
668
|
-
if (a.commentThread.range.startColumn < b.commentThread.range.startColumn) {
|
|
669
|
-
return -1;
|
|
670
|
-
}
|
|
671
|
-
if (a.commentThread.range.startColumn > b.commentThread.range.startColumn) {
|
|
672
|
-
return 1;
|
|
673
|
-
}
|
|
674
|
-
return 0;
|
|
675
|
-
});
|
|
676
|
-
const idx = findFirstIdxMonotonousOrArrLen(sortedWidgets, widget => {
|
|
677
|
-
const lineValueOne = reverse ? after.lineNumber : (widget.commentThread.range?.startLineNumber ?? 0);
|
|
678
|
-
const lineValueTwo = reverse ? (widget.commentThread.range?.startLineNumber ?? 0) : after.lineNumber;
|
|
679
|
-
const columnValueOne = reverse ? after.column : (widget.commentThread.range?.startColumn ?? 0);
|
|
680
|
-
const columnValueTwo = reverse ? (widget.commentThread.range?.startColumn ?? 0) : after.column;
|
|
681
|
-
if (lineValueOne > lineValueTwo) {
|
|
682
|
-
return true;
|
|
683
|
-
}
|
|
684
|
-
if (lineValueOne < lineValueTwo) {
|
|
685
|
-
return false;
|
|
686
|
-
}
|
|
687
|
-
if (columnValueOne > columnValueTwo) {
|
|
688
|
-
return true;
|
|
689
|
-
}
|
|
690
|
-
return false;
|
|
691
|
-
});
|
|
692
|
-
let nextWidget;
|
|
693
|
-
if (idx === this._commentWidgets.length) {
|
|
694
|
-
nextWidget = this._commentWidgets[0];
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
nextWidget = sortedWidgets[idx];
|
|
698
|
-
}
|
|
699
|
-
this.editor.setSelection(nextWidget.commentThread.range ?? ( new Range(1, 1, 1, 1)));
|
|
700
|
-
nextWidget.reveal(undefined, true);
|
|
701
|
-
}
|
|
702
|
-
previousCommentThread() {
|
|
703
|
-
this._findNearestCommentThread(true);
|
|
704
|
-
}
|
|
705
|
-
_findNearestCommentingRange(reverse) {
|
|
706
|
-
if (!this.editor?.hasModel()) {
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
const after = this.editor.getSelection().getEndPosition();
|
|
710
|
-
const range = this._commentingRangeDecorator.getNearestCommentingRange(after, reverse);
|
|
711
|
-
if (range) {
|
|
712
|
-
const position = reverse ? range.getEndPosition() : range.getStartPosition();
|
|
713
|
-
this.editor.setPosition(position);
|
|
714
|
-
this.editor.revealLineInCenterIfOutsideViewport(position.lineNumber);
|
|
715
|
-
}
|
|
716
|
-
if (this.accessibilityService.isScreenReaderOptimized()) {
|
|
717
|
-
const commentRangeStart = range?.getStartPosition().lineNumber;
|
|
718
|
-
const commentRangeEnd = range?.getEndPosition().lineNumber;
|
|
719
|
-
if (commentRangeStart && commentRangeEnd) {
|
|
720
|
-
const oneLine = commentRangeStart === commentRangeEnd;
|
|
721
|
-
oneLine ? status(( localizeWithPath(
|
|
722
|
-
'vs/workbench/contrib/comments/browser/commentsController',
|
|
723
|
-
'commentRange',
|
|
724
|
-
"Line {0}",
|
|
725
|
-
commentRangeStart
|
|
726
|
-
))) : status(( localizeWithPath(
|
|
727
|
-
'vs/workbench/contrib/comments/browser/commentsController',
|
|
728
|
-
'commentRangeStart',
|
|
729
|
-
"Lines {0} to {1}",
|
|
730
|
-
commentRangeStart,
|
|
731
|
-
commentRangeEnd
|
|
732
|
-
)));
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
nextCommentingRange() {
|
|
737
|
-
this._findNearestCommentingRange();
|
|
738
|
-
}
|
|
739
|
-
previousCommentingRange() {
|
|
740
|
-
this._findNearestCommentingRange(true);
|
|
741
|
-
}
|
|
742
|
-
dispose() {
|
|
743
|
-
this.globalToDispose.dispose();
|
|
744
|
-
this.localToDispose.dispose();
|
|
745
|
-
dispose(this._editorDisposables);
|
|
746
|
-
dispose(this._commentWidgets);
|
|
747
|
-
this.editor = null;
|
|
748
|
-
}
|
|
749
|
-
onModelChanged() {
|
|
750
|
-
this.localToDispose.clear();
|
|
751
|
-
this.removeCommentWidgetsAndStoreCache();
|
|
752
|
-
if (!this.editor) {
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
this._hasRespondedToEditorChange = false;
|
|
756
|
-
this.localToDispose.add(this.editor.onMouseDown(e => this.onEditorMouseDown(e)));
|
|
757
|
-
this.localToDispose.add(this.editor.onMouseUp(e => this.onEditorMouseUp(e)));
|
|
758
|
-
if (this._editorDisposables.length) {
|
|
759
|
-
this.clearEditorListeners();
|
|
760
|
-
this.registerEditorListeners();
|
|
761
|
-
}
|
|
762
|
-
this._computeCommentingRangeScheduler = ( new Delayer(200));
|
|
763
|
-
this.localToDispose.add({
|
|
764
|
-
dispose: () => {
|
|
765
|
-
this._computeCommentingRangeScheduler?.cancel();
|
|
766
|
-
this._computeCommentingRangeScheduler = null;
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
this.localToDispose.add(this.editor.onDidChangeModelContent(async () => {
|
|
770
|
-
this.beginComputeCommentingRanges();
|
|
771
|
-
}));
|
|
772
|
-
this.localToDispose.add(this.commentService.onDidUpdateCommentThreads(async (e) => {
|
|
773
|
-
const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri;
|
|
774
|
-
if (!editorURI || !this.commentService.isCommentingEnabled) {
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
if (this._computePromise) {
|
|
778
|
-
await this._computePromise;
|
|
779
|
-
}
|
|
780
|
-
const commentInfo = this._commentInfos.filter(info => info.owner === e.owner);
|
|
781
|
-
if (!commentInfo || !commentInfo.length) {
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
const added = e.added.filter(thread => thread.resource && thread.resource === ( editorURI.toString()));
|
|
785
|
-
const removed = e.removed.filter(thread => thread.resource && thread.resource === ( editorURI.toString()));
|
|
786
|
-
const changed = e.changed.filter(thread => thread.resource && thread.resource === ( editorURI.toString()));
|
|
787
|
-
const pending = e.pending.filter(pending => ( pending.uri.toString()) === ( editorURI.toString()));
|
|
788
|
-
removed.forEach(thread => {
|
|
789
|
-
const matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId && zoneWidget.commentThread.threadId !== '');
|
|
790
|
-
if (matchedZones.length) {
|
|
791
|
-
const matchedZone = matchedZones[0];
|
|
792
|
-
const index = this._commentWidgets.indexOf(matchedZone);
|
|
793
|
-
this._commentWidgets.splice(index, 1);
|
|
794
|
-
matchedZone.dispose();
|
|
795
|
-
}
|
|
796
|
-
const infosThreads = this._commentInfos.filter(info => info.owner === e.owner)[0].threads;
|
|
797
|
-
for (let i = 0; i < infosThreads.length; i++) {
|
|
798
|
-
if (infosThreads[i] === thread) {
|
|
799
|
-
infosThreads.splice(i, 1);
|
|
800
|
-
i--;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
changed.forEach(thread => {
|
|
805
|
-
const matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId);
|
|
806
|
-
if (matchedZones.length) {
|
|
807
|
-
const matchedZone = matchedZones[0];
|
|
808
|
-
matchedZone.update(thread);
|
|
809
|
-
this.openCommentsView(thread);
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
for (const thread of added) {
|
|
813
|
-
const matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId);
|
|
814
|
-
if (matchedZones.length) {
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
const matchedNewCommentThreadZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range));
|
|
818
|
-
if (matchedNewCommentThreadZones.length) {
|
|
819
|
-
matchedNewCommentThreadZones[0].update(thread);
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
const continueOnCommentIndex = this._inProcessContinueOnComments.get(e.owner)?.findIndex(pending => {
|
|
823
|
-
if (pending.range === undefined) {
|
|
824
|
-
return thread.range === undefined;
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
827
|
-
return Range.lift(pending.range).equalsRange(thread.range);
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
let continueOnCommentText;
|
|
831
|
-
if ((continueOnCommentIndex !== undefined) && continueOnCommentIndex >= 0) {
|
|
832
|
-
continueOnCommentText = this._inProcessContinueOnComments.get(e.owner)?.splice(continueOnCommentIndex, 1)[0].body;
|
|
833
|
-
}
|
|
834
|
-
const pendingCommentText = (this._pendingNewCommentCache[e.owner] && this._pendingNewCommentCache[e.owner][thread.threadId])
|
|
835
|
-
?? continueOnCommentText;
|
|
836
|
-
const pendingEdits = this._pendingEditsCache[e.owner] && this._pendingEditsCache[e.owner][thread.threadId];
|
|
837
|
-
this.displayCommentThread(e.owner, thread, pendingCommentText, pendingEdits);
|
|
838
|
-
this._commentInfos.filter(info => info.owner === e.owner)[0].threads.push(thread);
|
|
839
|
-
this.tryUpdateReservedSpace();
|
|
840
|
-
}
|
|
841
|
-
for (const thread of pending) {
|
|
842
|
-
await this.resumePendingComment(editorURI, thread);
|
|
843
|
-
}
|
|
844
|
-
this._commentThreadRangeDecorator.update(this.editor, commentInfo);
|
|
845
|
-
}));
|
|
846
|
-
this.beginComputeAndHandleEditorChange();
|
|
847
|
-
}
|
|
848
|
-
async resumePendingComment(editorURI, thread) {
|
|
849
|
-
const matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === thread.owner && Range.lift(zoneWidget.commentThread.range)?.equalsRange(thread.range));
|
|
850
|
-
if (thread.isReply && matchedZones.length) {
|
|
851
|
-
this.commentService.removeContinueOnComment({ owner: thread.owner, uri: editorURI, range: thread.range, isReply: true });
|
|
852
|
-
matchedZones[0].setPendingComment(thread.body);
|
|
853
|
-
}
|
|
854
|
-
else if (matchedZones.length) {
|
|
855
|
-
this.commentService.removeContinueOnComment({ owner: thread.owner, uri: editorURI, range: thread.range, isReply: false });
|
|
856
|
-
const existingPendingComment = matchedZones[0].getPendingComments().newComment;
|
|
857
|
-
let pendingComment;
|
|
858
|
-
if (!existingPendingComment || thread.body.includes(existingPendingComment)) {
|
|
859
|
-
pendingComment = thread.body;
|
|
860
|
-
}
|
|
861
|
-
else if (existingPendingComment.includes(thread.body)) {
|
|
862
|
-
pendingComment = existingPendingComment;
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
pendingComment = `${existingPendingComment}\n${thread.body}`;
|
|
866
|
-
}
|
|
867
|
-
matchedZones[0].setPendingComment(pendingComment);
|
|
868
|
-
}
|
|
869
|
-
else if (!thread.isReply) {
|
|
870
|
-
const threadStillAvailable = this.commentService.removeContinueOnComment({ owner: thread.owner, uri: editorURI, range: thread.range, isReply: false });
|
|
871
|
-
if (!threadStillAvailable) {
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
if (!( this._inProcessContinueOnComments.has(thread.owner))) {
|
|
875
|
-
this._inProcessContinueOnComments.set(thread.owner, []);
|
|
876
|
-
}
|
|
877
|
-
this._inProcessContinueOnComments.get(thread.owner)?.push(thread);
|
|
878
|
-
await this.commentService.createCommentThreadTemplate(thread.owner, thread.uri, thread.range ? Range.lift(thread.range) : undefined);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
beginComputeAndHandleEditorChange() {
|
|
882
|
-
this.beginCompute().then(() => {
|
|
883
|
-
if (!this._hasRespondedToEditorChange) {
|
|
884
|
-
if (( this._commentInfos.some(
|
|
885
|
-
commentInfo => commentInfo.commentingRanges.ranges.length > 0 || commentInfo.commentingRanges.fileComments
|
|
886
|
-
))) {
|
|
887
|
-
this._hasRespondedToEditorChange = true;
|
|
888
|
-
const verbose = this.configurationService.getValue("accessibility.verbosity.comments" );
|
|
889
|
-
if (verbose) {
|
|
890
|
-
const keybinding = this.keybindingService.lookupKeybinding("editor.action.accessibilityHelp" )?.getAriaLabel();
|
|
891
|
-
if (keybinding) {
|
|
892
|
-
status(( localizeWithPath(
|
|
893
|
-
'vs/workbench/contrib/comments/browser/commentsController',
|
|
894
|
-
'hasCommentRangesKb',
|
|
895
|
-
"Editor has commenting ranges, run the command Open Accessibility Help ({0}), for more information.",
|
|
896
|
-
keybinding
|
|
897
|
-
)));
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
900
|
-
status(( localizeWithPath(
|
|
901
|
-
'vs/workbench/contrib/comments/browser/commentsController',
|
|
902
|
-
'hasCommentRangesNoKb',
|
|
903
|
-
"Editor has commenting ranges, run the command Open Accessibility Help, which is currently not triggerable via keybinding, for more information."
|
|
904
|
-
)));
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
908
|
-
status(( localizeWithPath(
|
|
909
|
-
'vs/workbench/contrib/comments/browser/commentsController',
|
|
910
|
-
'hasCommentRanges',
|
|
911
|
-
"Editor has commenting ranges."
|
|
912
|
-
)));
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
async openCommentsView(thread) {
|
|
919
|
-
if (thread.comments && (thread.comments.length > 0)) {
|
|
920
|
-
const openViewState = this.configurationService.getValue(COMMENTS_SECTION).openView;
|
|
921
|
-
if (openViewState === 'file') {
|
|
922
|
-
return this.viewsService.openView(COMMENTS_VIEW_ID);
|
|
923
|
-
}
|
|
924
|
-
else if (openViewState === 'firstFile' || (openViewState === 'firstFileUnresolved' && thread.state === CommentThreadState.Unresolved)) {
|
|
925
|
-
const hasShownView = this.viewsService.getViewWithId(COMMENTS_VIEW_ID)?.hasRendered;
|
|
926
|
-
if (!hasShownView) {
|
|
927
|
-
return this.viewsService.openView(COMMENTS_VIEW_ID);
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
return undefined;
|
|
932
|
-
}
|
|
933
|
-
displayCommentThread(owner, thread, pendingComment, pendingEdits) {
|
|
934
|
-
const editor = this.editor?.getModel();
|
|
935
|
-
if (!editor) {
|
|
936
|
-
return;
|
|
937
|
-
}
|
|
938
|
-
if (!this.editor || this.isEditorInlineOriginal(this.editor)) {
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
let continueOnCommentReply;
|
|
942
|
-
if (thread.range && !pendingComment) {
|
|
943
|
-
continueOnCommentReply = this.commentService.removeContinueOnComment({ owner, uri: editor.uri, range: thread.range, isReply: true });
|
|
944
|
-
}
|
|
945
|
-
const zoneWidget = this.instantiationService.createInstance(ReviewZoneWidget, this.editor, owner, thread, pendingComment ?? continueOnCommentReply?.body, pendingEdits);
|
|
946
|
-
zoneWidget.display(thread.range);
|
|
947
|
-
this._commentWidgets.push(zoneWidget);
|
|
948
|
-
this.openCommentsView(thread);
|
|
949
|
-
}
|
|
950
|
-
onEditorMouseDown(e) {
|
|
951
|
-
this.mouseDownInfo = parseMouseDownInfoFromEvent(e);
|
|
952
|
-
}
|
|
953
|
-
onEditorMouseUp(e) {
|
|
954
|
-
const matchedLineNumber = isMouseUpEventDragFromMouseDown(this.mouseDownInfo, e);
|
|
955
|
-
this.mouseDownInfo = null;
|
|
956
|
-
if (!this.editor || matchedLineNumber === null || !e.target.element) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
const mouseUpIsOnDecorator = (e.target.element.className.indexOf('comment-range-glyph') >= 0);
|
|
960
|
-
const lineNumber = e.target.position.lineNumber;
|
|
961
|
-
let range;
|
|
962
|
-
let selection;
|
|
963
|
-
if ((matchedLineNumber !== lineNumber)) {
|
|
964
|
-
if (matchedLineNumber > lineNumber) {
|
|
965
|
-
selection = ( new Range(
|
|
966
|
-
matchedLineNumber,
|
|
967
|
-
this.editor.getModel().getLineLength(matchedLineNumber) + 1,
|
|
968
|
-
lineNumber,
|
|
969
|
-
1
|
|
970
|
-
));
|
|
971
|
-
}
|
|
972
|
-
else {
|
|
973
|
-
selection = ( new Range(
|
|
974
|
-
matchedLineNumber,
|
|
975
|
-
1,
|
|
976
|
-
lineNumber,
|
|
977
|
-
this.editor.getModel().getLineLength(lineNumber) + 1
|
|
978
|
-
));
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
else if (mouseUpIsOnDecorator) {
|
|
982
|
-
selection = this.editor.getSelection();
|
|
983
|
-
}
|
|
984
|
-
if (selection && (selection.startLineNumber <= lineNumber) && (lineNumber <= selection.endLineNumber)) {
|
|
985
|
-
range = selection;
|
|
986
|
-
this.editor.setSelection(( new Range(selection.endLineNumber, 1, selection.endLineNumber, 1)));
|
|
987
|
-
}
|
|
988
|
-
else if (mouseUpIsOnDecorator) {
|
|
989
|
-
range = ( new Range(lineNumber, 1, lineNumber, 1));
|
|
990
|
-
}
|
|
991
|
-
if (range) {
|
|
992
|
-
this.addOrToggleCommentAtLine(range, e);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
async addOrToggleCommentAtLine(commentRange, e) {
|
|
996
|
-
if (!this._addInProgress) {
|
|
997
|
-
this._addInProgress = true;
|
|
998
|
-
const existingCommentsAtLine = this._commentWidgets.filter(widget => widget.getGlyphPosition() === (commentRange ? commentRange.endLineNumber : 0));
|
|
999
|
-
if (existingCommentsAtLine.length) {
|
|
1000
|
-
const allExpanded = existingCommentsAtLine.every(widget => widget.expanded);
|
|
1001
|
-
existingCommentsAtLine.forEach(allExpanded ? widget => widget.collapse() : widget => widget.expand());
|
|
1002
|
-
this.processNextThreadToAdd();
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
else {
|
|
1006
|
-
this.addCommentAtLine(commentRange, e);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
else {
|
|
1010
|
-
this._emptyThreadsToAddQueue.push([commentRange, e]);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
processNextThreadToAdd() {
|
|
1014
|
-
this._addInProgress = false;
|
|
1015
|
-
const info = this._emptyThreadsToAddQueue.shift();
|
|
1016
|
-
if (info) {
|
|
1017
|
-
this.addOrToggleCommentAtLine(info[0], info[1]);
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
clipUserRangeToCommentRange(userRange, commentRange) {
|
|
1021
|
-
if (userRange.startLineNumber < commentRange.startLineNumber) {
|
|
1022
|
-
userRange = ( new Range(
|
|
1023
|
-
commentRange.startLineNumber,
|
|
1024
|
-
commentRange.startColumn,
|
|
1025
|
-
userRange.endLineNumber,
|
|
1026
|
-
userRange.endColumn
|
|
1027
|
-
));
|
|
1028
|
-
}
|
|
1029
|
-
if (userRange.endLineNumber > commentRange.endLineNumber) {
|
|
1030
|
-
userRange = ( new Range(
|
|
1031
|
-
userRange.startLineNumber,
|
|
1032
|
-
userRange.startColumn,
|
|
1033
|
-
commentRange.endLineNumber,
|
|
1034
|
-
commentRange.endColumn
|
|
1035
|
-
));
|
|
1036
|
-
}
|
|
1037
|
-
return userRange;
|
|
1038
|
-
}
|
|
1039
|
-
addCommentAtLine(range, e) {
|
|
1040
|
-
const newCommentInfos = this._commentingRangeDecorator.getMatchedCommentAction(range);
|
|
1041
|
-
if (!newCommentInfos.length || !this.editor?.hasModel()) {
|
|
1042
|
-
this._addInProgress = false;
|
|
1043
|
-
if (!newCommentInfos.length) {
|
|
1044
|
-
throw new Error('There are no commenting ranges at the current position.');
|
|
1045
|
-
}
|
|
1046
|
-
return Promise.resolve();
|
|
1047
|
-
}
|
|
1048
|
-
if (newCommentInfos.length > 1) {
|
|
1049
|
-
if (e && range) {
|
|
1050
|
-
this.contextMenuService.showContextMenu({
|
|
1051
|
-
getAnchor: () => e.event,
|
|
1052
|
-
getActions: () => this.getContextMenuActions(newCommentInfos, range),
|
|
1053
|
-
getActionsContext: () => newCommentInfos.length ? newCommentInfos[0] : undefined,
|
|
1054
|
-
onHide: () => { this._addInProgress = false; }
|
|
1055
|
-
});
|
|
1056
|
-
return Promise.resolve();
|
|
1057
|
-
}
|
|
1058
|
-
else {
|
|
1059
|
-
const picks = this.getCommentProvidersQuickPicks(newCommentInfos);
|
|
1060
|
-
return this.quickInputService.pick(picks, { placeHolder: ( localizeWithPath(
|
|
1061
|
-
'vs/workbench/contrib/comments/browser/commentsController',
|
|
1062
|
-
'pickCommentService',
|
|
1063
|
-
"Select Comment Provider"
|
|
1064
|
-
)), matchOnDescription: true }).then(pick => {
|
|
1065
|
-
if (!pick) {
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
const commentInfos = newCommentInfos.filter(info => info.action.ownerId === pick.id);
|
|
1069
|
-
if (commentInfos.length) {
|
|
1070
|
-
const { ownerId } = commentInfos[0].action;
|
|
1071
|
-
const clippedRange = range && commentInfos[0].range ? this.clipUserRangeToCommentRange(range, commentInfos[0].range) : range;
|
|
1072
|
-
this.addCommentAtLine2(clippedRange, ownerId);
|
|
1073
|
-
}
|
|
1074
|
-
}).then(() => {
|
|
1075
|
-
this._addInProgress = false;
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
else {
|
|
1080
|
-
const { ownerId } = newCommentInfos[0].action;
|
|
1081
|
-
const clippedRange = range && newCommentInfos[0].range ? this.clipUserRangeToCommentRange(range, newCommentInfos[0].range) : range;
|
|
1082
|
-
this.addCommentAtLine2(clippedRange, ownerId);
|
|
1083
|
-
}
|
|
1084
|
-
return Promise.resolve();
|
|
1085
|
-
}
|
|
1086
|
-
getCommentProvidersQuickPicks(commentInfos) {
|
|
1087
|
-
const picks = ( commentInfos.map((commentInfo) => {
|
|
1088
|
-
const { ownerId, extensionId, label } = commentInfo.action;
|
|
1089
|
-
return {
|
|
1090
|
-
label: label || extensionId,
|
|
1091
|
-
id: ownerId
|
|
1092
|
-
};
|
|
1093
|
-
}));
|
|
1094
|
-
return picks;
|
|
1095
|
-
}
|
|
1096
|
-
getContextMenuActions(commentInfos, commentRange) {
|
|
1097
|
-
const actions = [];
|
|
1098
|
-
commentInfos.forEach(commentInfo => {
|
|
1099
|
-
const { ownerId, extensionId, label } = commentInfo.action;
|
|
1100
|
-
actions.push(( new Action('addCommentThread', `${label || extensionId}`, undefined, true, () => {
|
|
1101
|
-
const clippedRange = commentInfo.range ? this.clipUserRangeToCommentRange(commentRange, commentInfo.range) : commentRange;
|
|
1102
|
-
this.addCommentAtLine2(clippedRange, ownerId);
|
|
1103
|
-
return Promise.resolve();
|
|
1104
|
-
})));
|
|
1105
|
-
});
|
|
1106
|
-
return actions;
|
|
1107
|
-
}
|
|
1108
|
-
addCommentAtLine2(range, ownerId) {
|
|
1109
|
-
if (!this.editor) {
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
this.commentService.createCommentThreadTemplate(ownerId, this.editor.getModel().uri, range);
|
|
1113
|
-
this.processNextThreadToAdd();
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
getExistingCommentEditorOptions(editor) {
|
|
1117
|
-
const lineDecorationsWidth = editor.getOption(65 );
|
|
1118
|
-
let extraEditorClassName = [];
|
|
1119
|
-
const configuredExtraClassName = editor.getRawOptions().extraEditorClassName;
|
|
1120
|
-
if (configuredExtraClassName) {
|
|
1121
|
-
extraEditorClassName = configuredExtraClassName.split(' ');
|
|
1122
|
-
}
|
|
1123
|
-
return { lineDecorationsWidth, extraEditorClassName };
|
|
1124
|
-
}
|
|
1125
|
-
getWithoutCommentsEditorOptions(editor, extraEditorClassName, startingLineDecorationsWidth) {
|
|
1126
|
-
let lineDecorationsWidth = startingLineDecorationsWidth;
|
|
1127
|
-
const inlineCommentPos = extraEditorClassName.findIndex(name => name === 'inline-comment');
|
|
1128
|
-
if (inlineCommentPos >= 0) {
|
|
1129
|
-
extraEditorClassName.splice(inlineCommentPos, 1);
|
|
1130
|
-
}
|
|
1131
|
-
const options = editor.getOptions();
|
|
1132
|
-
if (options.get(43 ) && options.get(109 ) !== 'never') {
|
|
1133
|
-
lineDecorationsWidth += 11;
|
|
1134
|
-
}
|
|
1135
|
-
lineDecorationsWidth -= 24;
|
|
1136
|
-
return { extraEditorClassName, lineDecorationsWidth };
|
|
1137
|
-
}
|
|
1138
|
-
getWithCommentsEditorOptions(editor, extraEditorClassName, startingLineDecorationsWidth) {
|
|
1139
|
-
let lineDecorationsWidth = startingLineDecorationsWidth;
|
|
1140
|
-
const options = editor.getOptions();
|
|
1141
|
-
if (options.get(43 ) && options.get(109 ) !== 'never') {
|
|
1142
|
-
lineDecorationsWidth -= 11;
|
|
1143
|
-
}
|
|
1144
|
-
lineDecorationsWidth += 24;
|
|
1145
|
-
extraEditorClassName.push('inline-comment');
|
|
1146
|
-
return { lineDecorationsWidth, extraEditorClassName };
|
|
1147
|
-
}
|
|
1148
|
-
updateEditorLayoutOptions(editor, extraEditorClassName, lineDecorationsWidth) {
|
|
1149
|
-
editor.updateOptions({
|
|
1150
|
-
extraEditorClassName: extraEditorClassName.join(' '),
|
|
1151
|
-
lineDecorationsWidth: lineDecorationsWidth
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
tryUpdateReservedSpace() {
|
|
1155
|
-
if (!this.editor) {
|
|
1156
|
-
return;
|
|
1157
|
-
}
|
|
1158
|
-
const hasCommentsOrRanges = ( this._commentInfos.some(info => {
|
|
1159
|
-
const hasRanges = Boolean(info.commentingRanges && (Array.isArray(info.commentingRanges) ? info.commentingRanges : info.commentingRanges.ranges).length);
|
|
1160
|
-
return hasRanges || (info.threads.length > 0);
|
|
1161
|
-
}));
|
|
1162
|
-
if (hasCommentsOrRanges && !this._commentingRangeSpaceReserved && this.commentService.isCommentingEnabled) {
|
|
1163
|
-
this._commentingRangeSpaceReserved = true;
|
|
1164
|
-
const { lineDecorationsWidth, extraEditorClassName } = this.getExistingCommentEditorOptions(this.editor);
|
|
1165
|
-
const newOptions = this.getWithCommentsEditorOptions(this.editor, extraEditorClassName, lineDecorationsWidth);
|
|
1166
|
-
this.updateEditorLayoutOptions(this.editor, newOptions.extraEditorClassName, newOptions.lineDecorationsWidth);
|
|
1167
|
-
}
|
|
1168
|
-
else if ((!hasCommentsOrRanges || !this.commentService.isCommentingEnabled) && this._commentingRangeSpaceReserved) {
|
|
1169
|
-
this._commentingRangeSpaceReserved = false;
|
|
1170
|
-
const { lineDecorationsWidth, extraEditorClassName } = this.getExistingCommentEditorOptions(this.editor);
|
|
1171
|
-
const newOptions = this.getWithoutCommentsEditorOptions(this.editor, extraEditorClassName, lineDecorationsWidth);
|
|
1172
|
-
this.updateEditorLayoutOptions(this.editor, newOptions.extraEditorClassName, newOptions.lineDecorationsWidth);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
setComments(commentInfos) {
|
|
1176
|
-
if (!this.editor || !this.commentService.isCommentingEnabled) {
|
|
1177
|
-
return;
|
|
1178
|
-
}
|
|
1179
|
-
this._commentInfos = commentInfos;
|
|
1180
|
-
this.tryUpdateReservedSpace();
|
|
1181
|
-
this.removeCommentWidgetsAndStoreCache();
|
|
1182
|
-
let hasCommentingRanges = false;
|
|
1183
|
-
this._commentInfos.forEach(info => {
|
|
1184
|
-
if (!hasCommentingRanges && (info.commentingRanges.ranges.length > 0 || info.commentingRanges.fileComments)) {
|
|
1185
|
-
hasCommentingRanges = true;
|
|
1186
|
-
}
|
|
1187
|
-
const providerCacheStore = this._pendingNewCommentCache[info.owner];
|
|
1188
|
-
const providerEditsCacheStore = this._pendingEditsCache[info.owner];
|
|
1189
|
-
info.threads = info.threads.filter(thread => !thread.isDisposed);
|
|
1190
|
-
info.threads.forEach(thread => {
|
|
1191
|
-
let pendingComment = undefined;
|
|
1192
|
-
if (providerCacheStore) {
|
|
1193
|
-
pendingComment = providerCacheStore[thread.threadId];
|
|
1194
|
-
}
|
|
1195
|
-
let pendingEdits = undefined;
|
|
1196
|
-
if (providerEditsCacheStore) {
|
|
1197
|
-
pendingEdits = providerEditsCacheStore[thread.threadId];
|
|
1198
|
-
}
|
|
1199
|
-
this.displayCommentThread(info.owner, thread, pendingComment, pendingEdits);
|
|
1200
|
-
});
|
|
1201
|
-
for (const thread of info.pendingCommentThreads ?? []) {
|
|
1202
|
-
this.resumePendingComment(this.editor.getModel().uri, thread);
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
|
-
this._commentingRangeDecorator.update(this.editor, this._commentInfos);
|
|
1206
|
-
this._commentThreadRangeDecorator.update(this.editor, this._commentInfos);
|
|
1207
|
-
if (hasCommentingRanges) {
|
|
1208
|
-
this._activeEditorHasCommentingRange.set(true);
|
|
1209
|
-
}
|
|
1210
|
-
else {
|
|
1211
|
-
this._activeEditorHasCommentingRange.set(false);
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
closeWidget() {
|
|
1215
|
-
this._commentWidgets?.forEach(widget => widget.hide());
|
|
1216
|
-
if (this.editor) {
|
|
1217
|
-
this.editor.focus();
|
|
1218
|
-
this.editor.revealRangeInCenter(this.editor.getSelection());
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
removeCommentWidgetsAndStoreCache() {
|
|
1222
|
-
if (this._commentWidgets) {
|
|
1223
|
-
this._commentWidgets.forEach(zone => {
|
|
1224
|
-
const pendingComments = zone.getPendingComments();
|
|
1225
|
-
const pendingNewComment = pendingComments.newComment;
|
|
1226
|
-
const providerNewCommentCacheStore = this._pendingNewCommentCache[zone.owner];
|
|
1227
|
-
let lastCommentBody;
|
|
1228
|
-
if (zone.commentThread.comments && zone.commentThread.comments.length) {
|
|
1229
|
-
const lastComment = zone.commentThread.comments[zone.commentThread.comments.length - 1];
|
|
1230
|
-
if (typeof lastComment.body === 'string') {
|
|
1231
|
-
lastCommentBody = lastComment.body;
|
|
1232
|
-
}
|
|
1233
|
-
else {
|
|
1234
|
-
lastCommentBody = lastComment.body.value;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
if (pendingNewComment && (pendingNewComment !== lastCommentBody)) {
|
|
1238
|
-
if (!providerNewCommentCacheStore) {
|
|
1239
|
-
this._pendingNewCommentCache[zone.owner] = {};
|
|
1240
|
-
}
|
|
1241
|
-
this._pendingNewCommentCache[zone.owner][zone.commentThread.threadId] = pendingNewComment;
|
|
1242
|
-
}
|
|
1243
|
-
else {
|
|
1244
|
-
if (providerNewCommentCacheStore) {
|
|
1245
|
-
delete providerNewCommentCacheStore[zone.commentThread.threadId];
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
const pendingEdits = pendingComments.edits;
|
|
1249
|
-
const providerEditsCacheStore = this._pendingEditsCache[zone.owner];
|
|
1250
|
-
if (( Object.keys(pendingEdits)).length > 0) {
|
|
1251
|
-
if (!providerEditsCacheStore) {
|
|
1252
|
-
this._pendingEditsCache[zone.owner] = {};
|
|
1253
|
-
}
|
|
1254
|
-
this._pendingEditsCache[zone.owner][zone.commentThread.threadId] = pendingEdits;
|
|
1255
|
-
}
|
|
1256
|
-
else if (providerEditsCacheStore) {
|
|
1257
|
-
delete providerEditsCacheStore[zone.commentThread.threadId];
|
|
1258
|
-
}
|
|
1259
|
-
zone.dispose();
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
this._commentWidgets = [];
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
CommentController = ( __decorate([
|
|
1266
|
-
( __param(1, ICommentService)),
|
|
1267
|
-
( __param(2, IInstantiationService)),
|
|
1268
|
-
( __param(3, ICodeEditorService)),
|
|
1269
|
-
( __param(4, IContextMenuService)),
|
|
1270
|
-
( __param(5, IQuickInputService)),
|
|
1271
|
-
( __param(6, IViewsService)),
|
|
1272
|
-
( __param(7, IConfigurationService)),
|
|
1273
|
-
( __param(8, IContextKeyService)),
|
|
1274
|
-
( __param(9, IEditorService)),
|
|
1275
|
-
( __param(10, IKeybindingService)),
|
|
1276
|
-
( __param(11, IAccessibilityService))
|
|
1277
|
-
], CommentController));
|
|
1278
|
-
|
|
1279
|
-
export { CommentController, ID };
|