@codingame/monaco-vscode-extensions-service-override 2.0.3 → 2.1.0
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 +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +22 -127
- package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +0 -5
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +3 -31
- package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +2 -1
- package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +32 -9
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +7 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +1 -1
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +1 -1
- package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +6 -5
- package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +3 -2
- package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +11 -8
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +2 -2
- package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +1 -1
- package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +27 -105
- package/vscode/src/vs/workbench/api/browser/mainThreadSpeech.js +37 -10
- package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +14 -16
- package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +5 -1
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +4 -1
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +5 -1
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +125 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +3 -2
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +22 -114
- package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +1 -120
|
@@ -4,7 +4,7 @@ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
|
4
4
|
import { renderMarkdown } from 'vscode/vscode/vs/base/browser/markdownRenderer';
|
|
5
5
|
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
6
|
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
7
|
-
import { CommentNode, ResourceWithCommentThreads
|
|
7
|
+
import { CommentNode, ResourceWithCommentThreads } from '../common/commentModel.js';
|
|
8
8
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
9
9
|
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
10
10
|
import { IListService, WorkbenchObjectTree } from 'vscode/vscode/vs/platform/list/browser/listService';
|
|
@@ -17,7 +17,8 @@ import { commentViewThreadStateColorVar, getCommentThreadStateIconColor } from '
|
|
|
17
17
|
import { CommentThreadState } from 'vscode/vscode/vs/editor/common/languages';
|
|
18
18
|
import { FilterOptions } from './commentsFilterOptions.js';
|
|
19
19
|
import { basename } from 'vscode/vscode/vs/base/common/resources';
|
|
20
|
-
import { openLinkFromMarkdown } from 'vscode/vscode/vs/editor/
|
|
20
|
+
import { openLinkFromMarkdown } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
|
|
21
|
+
import { CommentsModel } from './commentsModel.js';
|
|
21
22
|
|
|
22
23
|
const COMMENTS_VIEW_ID = 'workbench.panel.comments';
|
|
23
24
|
const COMMENTS_VIEW_STORAGE_ID = 'Comments';
|
|
@@ -6,37 +6,33 @@ import { basename } from 'vscode/vscode/vs/base/common/resources';
|
|
|
6
6
|
import { isDiffEditor, isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
7
7
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
8
8
|
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
9
|
-
import {
|
|
9
|
+
import { ResourceWithCommentThreads, CommentNode } from '../common/commentModel.js';
|
|
10
10
|
import { ICommentService } from 'vscode/vscode/vs/workbench/contrib/comments/browser/commentService';
|
|
11
11
|
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
12
|
-
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
13
12
|
import { textLinkForeground, textLinkActiveForeground, focusBorder, textPreformatForeground } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
|
|
14
13
|
import { ResourceLabels } from 'vscode/vscode/vs/workbench/browser/labels';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { Filter, CommentsList, COMMENTS_VIEW_TITLE } from './commentsTreeViewer.js';
|
|
15
|
+
import { FilterViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
|
|
16
|
+
import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
|
|
18
17
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
19
|
-
import { RawContextKey,
|
|
18
|
+
import { RawContextKey, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
20
19
|
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
21
20
|
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
22
21
|
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
23
22
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
24
23
|
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
25
|
-
import { registerAction2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
26
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
27
24
|
import { TextModel } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
28
25
|
import { CommentsViewFilterFocusContextKey } from './comments.js';
|
|
29
26
|
import { CommentsFilters } from './commentsViewActions.js';
|
|
30
27
|
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
31
28
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
32
29
|
import { FilterOptions } from './commentsFilterOptions.js';
|
|
33
|
-
import
|
|
34
|
-
import { CommentThreadState } from 'vscode/vscode/vs/editor/common/languages';
|
|
35
|
-
import { MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
30
|
+
import 'vscode/vscode/vs/editor/common/languages';
|
|
36
31
|
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
37
32
|
import { CommentController } from './commentsController.js';
|
|
38
33
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
39
34
|
import { registerNavigableContainer } from 'vscode/vscode/vs/workbench/browser/actions/widgetNavigationCommands';
|
|
35
|
+
import { CommentsModel } from './commentsModel.js';
|
|
40
36
|
|
|
41
37
|
const CONTEXT_KEY_HAS_COMMENTS = ( new RawContextKey('commentsView.hasComments', false));
|
|
42
38
|
const CONTEXT_KEY_SOME_COMMENTS_EXPANDED = ( new RawContextKey('commentsView.someCommentsExpanded', false));
|
|
@@ -49,7 +45,7 @@ function createResourceCommentsIterator(model) {
|
|
|
49
45
|
}));
|
|
50
46
|
}
|
|
51
47
|
let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
52
|
-
constructor(options, instantiationService, viewDescriptorService, editorService, configurationService, contextKeyService, contextMenuService, keybindingService, openerService, themeService, commentService, telemetryService, uriIdentityService,
|
|
48
|
+
constructor(options, instantiationService, viewDescriptorService, editorService, configurationService, contextKeyService, contextMenuService, keybindingService, openerService, themeService, commentService, telemetryService, uriIdentityService, storageService) {
|
|
53
49
|
const stateMemento = ( new Memento(VIEW_STORAGE_ID, storageService));
|
|
54
50
|
const viewState = stateMemento.getMemento(1 , 1 );
|
|
55
51
|
super({
|
|
@@ -73,10 +69,7 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
73
69
|
this.editorService = editorService;
|
|
74
70
|
this.commentService = commentService;
|
|
75
71
|
this.uriIdentityService = uriIdentityService;
|
|
76
|
-
this.activityService = activityService;
|
|
77
72
|
this.totalComments = 0;
|
|
78
|
-
this.totalUnresolved = 0;
|
|
79
|
-
this.activity = this._register(( new MutableDisposable()));
|
|
80
73
|
this.currentHeight = 0;
|
|
81
74
|
this.currentWidth = 0;
|
|
82
75
|
this.cachedFilterStats = undefined;
|
|
@@ -101,19 +94,6 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
101
94
|
}));
|
|
102
95
|
this._register(this.filterWidget.onDidChangeFilterText(() => this.updateFilter()));
|
|
103
96
|
}
|
|
104
|
-
updateBadge(unresolved) {
|
|
105
|
-
if (unresolved === this.totalUnresolved) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
this.totalUnresolved = unresolved;
|
|
109
|
-
const message = ( localizeWithPath(
|
|
110
|
-
'vs/workbench/contrib/comments/browser/commentsView',
|
|
111
|
-
'totalUnresolvedComments',
|
|
112
|
-
'{0} Unresolved Comments',
|
|
113
|
-
this.totalUnresolved
|
|
114
|
-
));
|
|
115
|
-
this.activity.value = this.activityService.showViewActivity(this.id, { badge: ( new NumberBadge(this.totalUnresolved, () => message)) });
|
|
116
|
-
}
|
|
117
97
|
saveState() {
|
|
118
98
|
this.viewState['filter'] = this.filterWidget.getFilterText();
|
|
119
99
|
this.viewState['filterHistory'] = this.filterWidget.getHistory();
|
|
@@ -177,7 +157,6 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
177
157
|
const domContainer = append(container, $('.comments-panel-container'));
|
|
178
158
|
this.treeContainer = append(domContainer, $('.tree-container'));
|
|
179
159
|
this.treeContainer.classList.add('file-icon-themable-tree', 'show-file-icons');
|
|
180
|
-
this.commentsModel = ( new CommentsModel());
|
|
181
160
|
this.cachedFilterStats = undefined;
|
|
182
161
|
this.createTree();
|
|
183
162
|
this.createMessageBox(domContainer);
|
|
@@ -200,7 +179,7 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
200
179
|
if (element && isActiveElement(element)) {
|
|
201
180
|
return;
|
|
202
181
|
}
|
|
203
|
-
if (!this.commentsModel.hasCommentThreads() && this.messageBoxContainer) {
|
|
182
|
+
if (!this.commentService.commentsModel.hasCommentThreads() && this.messageBoxContainer) {
|
|
204
183
|
this.messageBoxContainer.focus();
|
|
205
184
|
}
|
|
206
185
|
else if (this.tree) {
|
|
@@ -229,9 +208,9 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
229
208
|
styleElement.textContent = content.join('\n');
|
|
230
209
|
}
|
|
231
210
|
async renderComments() {
|
|
232
|
-
this.treeContainer.classList.toggle('hidden', !this.commentsModel.hasCommentThreads());
|
|
211
|
+
this.treeContainer.classList.toggle('hidden', !this.commentService.commentsModel.hasCommentThreads());
|
|
233
212
|
this.renderMessage();
|
|
234
|
-
await this.tree?.setChildren(null, createResourceCommentsIterator(this.commentsModel));
|
|
213
|
+
await this.tree?.setChildren(null, createResourceCommentsIterator(this.commentService.commentsModel));
|
|
235
214
|
}
|
|
236
215
|
collapseAll() {
|
|
237
216
|
if (this.tree) {
|
|
@@ -267,8 +246,8 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
267
246
|
this.messageBoxContainer.setAttribute('tabIndex', '0');
|
|
268
247
|
}
|
|
269
248
|
renderMessage() {
|
|
270
|
-
this.messageBoxContainer.textContent = this.commentsModel.getMessage();
|
|
271
|
-
this.messageBoxContainer.classList.toggle('hidden', this.commentsModel.hasCommentThreads());
|
|
249
|
+
this.messageBoxContainer.textContent = this.commentService.commentsModel.getMessage();
|
|
250
|
+
this.messageBoxContainer.classList.toggle('hidden', this.commentService.commentsModel.hasCommentThreads());
|
|
272
251
|
}
|
|
273
252
|
createTree() {
|
|
274
253
|
this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));
|
|
@@ -391,13 +370,13 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
391
370
|
return;
|
|
392
371
|
}
|
|
393
372
|
if (this.isVisible()) {
|
|
394
|
-
this.hasCommentsContextKey.set(this.commentsModel.hasCommentThreads());
|
|
395
|
-
this.treeContainer.classList.toggle('hidden', !this.commentsModel.hasCommentThreads());
|
|
373
|
+
this.hasCommentsContextKey.set(this.commentService.commentsModel.hasCommentThreads());
|
|
374
|
+
this.treeContainer.classList.toggle('hidden', !this.commentService.commentsModel.hasCommentThreads());
|
|
396
375
|
this.cachedFilterStats = undefined;
|
|
397
376
|
this.renderMessage();
|
|
398
|
-
this.tree?.setChildren(null, createResourceCommentsIterator(this.commentsModel));
|
|
399
|
-
if (this.tree.getSelection().length === 0 && this.commentsModel.hasCommentThreads()) {
|
|
400
|
-
const firstComment = this.commentsModel.resourceCommentThreads[0].commentThreads[0];
|
|
377
|
+
this.tree?.setChildren(null, createResourceCommentsIterator(this.commentService.commentsModel));
|
|
378
|
+
if (this.tree.getSelection().length === 0 && this.commentService.commentsModel.hasCommentThreads()) {
|
|
379
|
+
const firstComment = this.commentService.commentsModel.resourceCommentThreads[0].commentThreads[0];
|
|
401
380
|
if (firstComment) {
|
|
402
381
|
this.tree.setFocus([firstComment]);
|
|
403
382
|
this.tree.setSelection([firstComment]);
|
|
@@ -407,38 +386,23 @@ let CommentsPanel = class CommentsPanel extends FilterViewPane {
|
|
|
407
386
|
}
|
|
408
387
|
onAllCommentsChanged(e) {
|
|
409
388
|
this.cachedFilterStats = undefined;
|
|
410
|
-
this.commentsModel.setCommentThreads(e.ownerId, e.ownerLabel, e.commentThreads);
|
|
411
389
|
this.totalComments += e.commentThreads.length;
|
|
412
|
-
let unresolved = 0;
|
|
413
390
|
for (const thread of e.commentThreads) {
|
|
414
|
-
if (thread.state === CommentThreadState.Unresolved) {
|
|
415
|
-
unresolved++;
|
|
416
|
-
}
|
|
417
391
|
}
|
|
418
|
-
this.updateBadge(unresolved);
|
|
419
392
|
this.refresh();
|
|
420
393
|
}
|
|
421
394
|
onCommentsUpdated(e) {
|
|
422
395
|
this.cachedFilterStats = undefined;
|
|
423
|
-
const didUpdate = this.commentsModel.updateCommentThreads(e);
|
|
424
396
|
this.totalComments += e.added.length;
|
|
425
397
|
this.totalComments -= e.removed.length;
|
|
426
|
-
|
|
427
|
-
for (const resource of this.commentsModel.resourceCommentThreads) {
|
|
398
|
+
for (const resource of this.commentService.commentsModel.resourceCommentThreads) {
|
|
428
399
|
for (const thread of resource.commentThreads) {
|
|
429
|
-
if (thread.threadState === CommentThreadState.Unresolved) {
|
|
430
|
-
unresolved++;
|
|
431
|
-
}
|
|
432
400
|
}
|
|
433
401
|
}
|
|
434
|
-
this.
|
|
435
|
-
if (didUpdate) {
|
|
436
|
-
this.refresh();
|
|
437
|
-
}
|
|
402
|
+
this.refresh();
|
|
438
403
|
}
|
|
439
404
|
onDataProviderDeleted(owner) {
|
|
440
405
|
this.cachedFilterStats = undefined;
|
|
441
|
-
this.commentsModel.deleteCommentsByOwner(owner);
|
|
442
406
|
this.totalComments = 0;
|
|
443
407
|
this.refresh();
|
|
444
408
|
}
|
|
@@ -483,63 +447,7 @@ CommentsPanel = ( __decorate([
|
|
|
483
447
|
( __param(10, ICommentService)),
|
|
484
448
|
( __param(11, ITelemetryService)),
|
|
485
449
|
( __param(12, IUriIdentityService)),
|
|
486
|
-
( __param(13,
|
|
487
|
-
( __param(14, IStorageService))
|
|
450
|
+
( __param(13, IStorageService))
|
|
488
451
|
], CommentsPanel));
|
|
489
|
-
CommandsRegistry.registerCommand({
|
|
490
|
-
id: 'workbench.action.focusCommentsPanel',
|
|
491
|
-
handler: async (accessor) => {
|
|
492
|
-
const viewsService = accessor.get(IViewsService);
|
|
493
|
-
viewsService.openView(COMMENTS_VIEW_ID, true);
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
registerAction2(class Collapse extends ViewAction {
|
|
497
|
-
constructor() {
|
|
498
|
-
super({
|
|
499
|
-
viewId: COMMENTS_VIEW_ID,
|
|
500
|
-
id: 'comments.collapse',
|
|
501
|
-
title: ( localizeWithPath(
|
|
502
|
-
'vs/workbench/contrib/comments/browser/commentsView',
|
|
503
|
-
'collapseAll',
|
|
504
|
-
"Collapse All"
|
|
505
|
-
)),
|
|
506
|
-
f1: false,
|
|
507
|
-
icon: Codicon.collapseAll,
|
|
508
|
-
menu: {
|
|
509
|
-
id: MenuId.ViewTitle,
|
|
510
|
-
group: 'navigation',
|
|
511
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.and(( ContextKeyExpr.equals('view', COMMENTS_VIEW_ID)), CONTEXT_KEY_HAS_COMMENTS)), CONTEXT_KEY_SOME_COMMENTS_EXPANDED)),
|
|
512
|
-
order: 100
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
runInView(_accessor, view) {
|
|
517
|
-
view.collapseAll();
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
registerAction2(class Expand extends ViewAction {
|
|
521
|
-
constructor() {
|
|
522
|
-
super({
|
|
523
|
-
viewId: COMMENTS_VIEW_ID,
|
|
524
|
-
id: 'comments.expand',
|
|
525
|
-
title: ( localizeWithPath(
|
|
526
|
-
'vs/workbench/contrib/comments/browser/commentsView',
|
|
527
|
-
'expandAll',
|
|
528
|
-
"Expand All"
|
|
529
|
-
)),
|
|
530
|
-
f1: false,
|
|
531
|
-
icon: Codicon.expandAll,
|
|
532
|
-
menu: {
|
|
533
|
-
id: MenuId.ViewTitle,
|
|
534
|
-
group: 'navigation',
|
|
535
|
-
when: ( ContextKeyExpr.and(( ContextKeyExpr.and(( ContextKeyExpr.equals('view', COMMENTS_VIEW_ID)), CONTEXT_KEY_HAS_COMMENTS)), ContextKeyExpr.not(CONTEXT_KEY_SOME_COMMENTS_EXPANDED.key))),
|
|
536
|
-
order: 100
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
runInView(_accessor, view) {
|
|
541
|
-
view.expandAll();
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
452
|
|
|
545
|
-
export { CommentsPanel };
|
|
453
|
+
export { CONTEXT_KEY_HAS_COMMENTS, CONTEXT_KEY_SOME_COMMENTS_EXPANDED, CommentsPanel };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
2
|
-
import { groupBy } from 'vscode/vscode/vs/base/common/arrays';
|
|
3
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
-
|
|
5
1
|
class CommentNode {
|
|
6
2
|
constructor(owner, threadId, resource, comment, range, threadState) {
|
|
7
3
|
this.replies = [];
|
|
@@ -36,120 +32,5 @@ class ResourceWithCommentThreads {
|
|
|
36
32
|
return commentNodes[0];
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
class CommentsModel {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.resourceCommentThreads = [];
|
|
42
|
-
this.commentThreadsMap = ( new Map());
|
|
43
|
-
}
|
|
44
|
-
updateResourceCommentThreads() {
|
|
45
|
-
const includeLabel = this.commentThreadsMap.size > 1;
|
|
46
|
-
this.resourceCommentThreads = ( [...( this.commentThreadsMap.values())].map(value => {
|
|
47
|
-
return ( value.resourceWithCommentThreads.map(resource => {
|
|
48
|
-
resource.ownerLabel = includeLabel ? value.ownerLabel : undefined;
|
|
49
|
-
return resource;
|
|
50
|
-
})).flat();
|
|
51
|
-
})).flat();
|
|
52
|
-
this.resourceCommentThreads.sort((a, b) => {
|
|
53
|
-
return ( a.resource.toString()) > ( b.resource.toString()) ? 1 : -1;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
setCommentThreads(owner, ownerLabel, commentThreads) {
|
|
57
|
-
this.commentThreadsMap.set(owner, { ownerLabel, resourceWithCommentThreads: this.groupByResource(owner, commentThreads) });
|
|
58
|
-
this.updateResourceCommentThreads();
|
|
59
|
-
}
|
|
60
|
-
deleteCommentsByOwner(owner) {
|
|
61
|
-
if (owner) {
|
|
62
|
-
const existingOwner = this.commentThreadsMap.get(owner);
|
|
63
|
-
this.commentThreadsMap.set(owner, { ownerLabel: existingOwner?.ownerLabel, resourceWithCommentThreads: [] });
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.commentThreadsMap.clear();
|
|
67
|
-
}
|
|
68
|
-
this.updateResourceCommentThreads();
|
|
69
|
-
}
|
|
70
|
-
updateCommentThreads(event) {
|
|
71
|
-
const { owner, ownerLabel, removed, changed, added } = event;
|
|
72
|
-
const threadsForOwner = this.commentThreadsMap.get(owner)?.resourceWithCommentThreads || [];
|
|
73
|
-
removed.forEach(thread => {
|
|
74
|
-
const matchingResourceIndex = threadsForOwner.findIndex((resourceData) => resourceData.id === thread.resource);
|
|
75
|
-
const matchingResourceData = matchingResourceIndex >= 0 ? threadsForOwner[matchingResourceIndex] : undefined;
|
|
76
|
-
const index = matchingResourceData?.commentThreads.findIndex((commentThread) => commentThread.threadId === thread.threadId) ?? 0;
|
|
77
|
-
if (index >= 0) {
|
|
78
|
-
matchingResourceData?.commentThreads.splice(index, 1);
|
|
79
|
-
}
|
|
80
|
-
if (matchingResourceData?.commentThreads.length === 0) {
|
|
81
|
-
threadsForOwner.splice(matchingResourceIndex, 1);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
changed.forEach(thread => {
|
|
85
|
-
const matchingResourceIndex = threadsForOwner.findIndex((resourceData) => resourceData.id === thread.resource);
|
|
86
|
-
const matchingResourceData = matchingResourceIndex >= 0 ? threadsForOwner[matchingResourceIndex] : undefined;
|
|
87
|
-
if (!matchingResourceData) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const index = matchingResourceData.commentThreads.findIndex((commentThread) => commentThread.threadId === thread.threadId);
|
|
91
|
-
if (index >= 0) {
|
|
92
|
-
matchingResourceData.commentThreads[index] = ResourceWithCommentThreads.createCommentNode(owner, ( URI.parse(matchingResourceData.id)), thread);
|
|
93
|
-
}
|
|
94
|
-
else if (thread.comments && thread.comments.length) {
|
|
95
|
-
matchingResourceData.commentThreads.push(ResourceWithCommentThreads.createCommentNode(owner, ( URI.parse(matchingResourceData.id)), thread));
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
added.forEach(thread => {
|
|
99
|
-
const existingResource = threadsForOwner.filter(resourceWithThreads => ( resourceWithThreads.resource.toString()) === thread.resource);
|
|
100
|
-
if (existingResource.length) {
|
|
101
|
-
const resource = existingResource[0];
|
|
102
|
-
if (thread.comments && thread.comments.length) {
|
|
103
|
-
resource.commentThreads.push(ResourceWithCommentThreads.createCommentNode(owner, resource.resource, thread));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
threadsForOwner.push(( new ResourceWithCommentThreads(owner, ( URI.parse(thread.resource)), [thread])));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
this.commentThreadsMap.set(owner, { ownerLabel, resourceWithCommentThreads: threadsForOwner });
|
|
111
|
-
this.updateResourceCommentThreads();
|
|
112
|
-
return removed.length > 0 || changed.length > 0 || added.length > 0;
|
|
113
|
-
}
|
|
114
|
-
hasCommentThreads() {
|
|
115
|
-
return !!this.resourceCommentThreads.length;
|
|
116
|
-
}
|
|
117
|
-
getMessage() {
|
|
118
|
-
if (!this.resourceCommentThreads.length) {
|
|
119
|
-
return ( localizeWithPath(
|
|
120
|
-
'vs/workbench/contrib/comments/common/commentModel',
|
|
121
|
-
'noComments',
|
|
122
|
-
"There are no comments in this workspace yet."
|
|
123
|
-
));
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
return '';
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
groupByResource(owner, commentThreads) {
|
|
130
|
-
const resourceCommentThreads = [];
|
|
131
|
-
const commentThreadsByResource = ( new Map());
|
|
132
|
-
for (const group of groupBy(commentThreads, CommentsModel._compareURIs)) {
|
|
133
|
-
commentThreadsByResource.set(group[0].resource, ( new ResourceWithCommentThreads(owner, ( URI.parse(group[0].resource)), group)));
|
|
134
|
-
}
|
|
135
|
-
commentThreadsByResource.forEach((v, i, m) => {
|
|
136
|
-
resourceCommentThreads.push(v);
|
|
137
|
-
});
|
|
138
|
-
return resourceCommentThreads;
|
|
139
|
-
}
|
|
140
|
-
static _compareURIs(a, b) {
|
|
141
|
-
const resourceA = ( a.resource.toString());
|
|
142
|
-
const resourceB = ( b.resource.toString());
|
|
143
|
-
if (resourceA < resourceB) {
|
|
144
|
-
return -1;
|
|
145
|
-
}
|
|
146
|
-
else if (resourceA > resourceB) {
|
|
147
|
-
return 1;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
35
|
|
|
155
|
-
export { CommentNode,
|
|
36
|
+
export { CommentNode, ResourceWithCommentThreads };
|