@opensumi/ide-comments 3.9.1-next-1749546307.0 → 3.9.1-next-1749547010.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/lib/browser/comments-thread.d.ts +2 -0
- package/lib/browser/comments-thread.d.ts.map +1 -1
- package/lib/browser/comments-thread.js +33 -5
- package/lib/browser/comments-thread.js.map +1 -1
- package/lib/browser/comments-zone.view.d.ts.map +1 -1
- package/lib/browser/comments-zone.view.js +4 -0
- package/lib/browser/comments-zone.view.js.map +1 -1
- package/lib/browser/comments.service.d.ts +3 -0
- package/lib/browser/comments.service.d.ts.map +1 -1
- package/lib/browser/comments.service.js +176 -125
- package/lib/browser/comments.service.js.map +1 -1
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/package.json +11 -11
- package/src/browser/comments-thread.ts +35 -5
- package/src/browser/comments-zone.view.tsx +5 -0
- package/src/browser/comments.service.ts +193 -135
- package/src/common/index.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-comments",
|
|
3
|
-
"version": "3.9.1-next-
|
|
3
|
+
"version": "3.9.1-next-1749547010.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"url": "git@github.com:opensumi/core.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@opensumi/ide-core-common": "3.9.1-next-
|
|
20
|
+
"@opensumi/ide-core-common": "3.9.1-next-1749547010.0",
|
|
21
21
|
"react-mentions": "^4.4.10"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@opensumi/ide-components": "3.9.1-next-
|
|
25
|
-
"@opensumi/ide-core-browser": "3.9.1-next-
|
|
26
|
-
"@opensumi/ide-dev-tool": "3.9.1-next-
|
|
27
|
-
"@opensumi/ide-editor": "3.9.1-next-
|
|
28
|
-
"@opensumi/ide-main-layout": "3.9.1-next-
|
|
29
|
-
"@opensumi/ide-monaco": "3.9.1-next-
|
|
30
|
-
"@opensumi/ide-monaco-enhance": "3.9.1-next-
|
|
31
|
-
"@opensumi/ide-theme": "3.9.1-next-
|
|
24
|
+
"@opensumi/ide-components": "3.9.1-next-1749547010.0",
|
|
25
|
+
"@opensumi/ide-core-browser": "3.9.1-next-1749547010.0",
|
|
26
|
+
"@opensumi/ide-dev-tool": "3.9.1-next-1749547010.0",
|
|
27
|
+
"@opensumi/ide-editor": "3.9.1-next-1749547010.0",
|
|
28
|
+
"@opensumi/ide-main-layout": "3.9.1-next-1749547010.0",
|
|
29
|
+
"@opensumi/ide-monaco": "3.9.1-next-1749547010.0",
|
|
30
|
+
"@opensumi/ide-monaco-enhance": "3.9.1-next-1749547010.0",
|
|
31
|
+
"@opensumi/ide-theme": "3.9.1-next-1749547010.0",
|
|
32
32
|
"@types/react-mentions": "^4.1.13"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f4f48c465e691f24756394ae1a7c524f5eda57e5"
|
|
35
35
|
}
|
|
@@ -59,6 +59,9 @@ export class CommentsThread extends Disposable implements ICommentsThread {
|
|
|
59
59
|
|
|
60
60
|
private onDidChangeEmitter: Emitter<void> = new Emitter();
|
|
61
61
|
|
|
62
|
+
// 用于跟踪待执行的 setTimeout,避免快速滚动时的竞态条件
|
|
63
|
+
private pendingShowTimeouts = new Set<NodeJS.Timeout>();
|
|
64
|
+
|
|
62
65
|
get onDidChange() {
|
|
63
66
|
return this.onDidChangeEmitter.event;
|
|
64
67
|
}
|
|
@@ -111,6 +114,14 @@ export class CommentsThread extends Disposable implements ICommentsThread {
|
|
|
111
114
|
commentThreadIsEmptyContext.set(!length);
|
|
112
115
|
}),
|
|
113
116
|
);
|
|
117
|
+
const editors = this.getEditorsByUri(this.uri);
|
|
118
|
+
editors.forEach((editor) => {
|
|
119
|
+
const widget = this.widgets.get(editor);
|
|
120
|
+
// 说明是在新的 group 中打开
|
|
121
|
+
if (!widget) {
|
|
122
|
+
this.addWidgetByEditor(editor);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
114
125
|
this.addDispose(
|
|
115
126
|
autorun((reader) => {
|
|
116
127
|
const isCollapsed = this.isCollapsed.read(reader);
|
|
@@ -132,6 +143,9 @@ export class CommentsThread extends Disposable implements ICommentsThread {
|
|
|
132
143
|
this.addDispose({
|
|
133
144
|
dispose: () => {
|
|
134
145
|
this.updateComments([]);
|
|
146
|
+
// 清理待执行的 timeout
|
|
147
|
+
this.pendingShowTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
148
|
+
this.pendingShowTimeouts.clear();
|
|
135
149
|
},
|
|
136
150
|
});
|
|
137
151
|
this.onDidChangeEmitter.fire();
|
|
@@ -182,7 +196,7 @@ export class CommentsThread extends Disposable implements ICommentsThread {
|
|
|
182
196
|
|
|
183
197
|
private addWidgetByEditor(editor: IEditor) {
|
|
184
198
|
const widget = this.injector.get(CommentsZoneWidget, [editor, this, { arrowColor: 'var(--peekView-border)' }]);
|
|
185
|
-
// 如果当前 widget 发生高度变化,通知同一个
|
|
199
|
+
// 如果当前 widget 发生高度变化,通知同一个 editor 的其他 range 相同的 thread 也重新计算一下高度
|
|
186
200
|
this.addDispose(
|
|
187
201
|
widget.onChangeZoneWidget(() => {
|
|
188
202
|
const threads = this.commentsService.commentsThreads.filter((thread) => this.isEqual(thread));
|
|
@@ -236,14 +250,23 @@ export class CommentsThread extends Disposable implements ICommentsThread {
|
|
|
236
250
|
widget = this.addWidgetByEditor(editor);
|
|
237
251
|
}
|
|
238
252
|
// 如果标记之前是已经展示的 widget,则调用 show 方法
|
|
239
|
-
if (editor.currentUri?.isEqual(this.uri)) {
|
|
253
|
+
if (widget && editor.currentUri?.isEqual(this.uri)) {
|
|
240
254
|
widget.show();
|
|
241
255
|
}
|
|
242
256
|
});
|
|
243
257
|
}
|
|
244
258
|
}
|
|
245
259
|
|
|
260
|
+
public removePaddingShowedWidgets() {
|
|
261
|
+
this.pendingShowTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
262
|
+
this.pendingShowTimeouts.clear();
|
|
263
|
+
}
|
|
264
|
+
|
|
246
265
|
public showWidgetsIfShowed() {
|
|
266
|
+
// 清除之前的待执行 timeout,避免竞态条件
|
|
267
|
+
this.pendingShowTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
268
|
+
this.pendingShowTimeouts.clear();
|
|
269
|
+
|
|
247
270
|
for (const editor of this.getEditorsByUri(this.uri)) {
|
|
248
271
|
let widget = this.widgets.get(editor);
|
|
249
272
|
// 说明是在新的 group 中打开
|
|
@@ -252,9 +275,16 @@ export class CommentsThread extends Disposable implements ICommentsThread {
|
|
|
252
275
|
}
|
|
253
276
|
// 如果标记之前是已经展示的 widget,则调用 show 方法
|
|
254
277
|
if (editor.currentUri?.isEqual(this.uri)) {
|
|
255
|
-
setTimeout(() => {
|
|
256
|
-
|
|
257
|
-
|
|
278
|
+
const timeout = setTimeout(() => {
|
|
279
|
+
// 在异步回调中再次检查编辑器的当前 URI 是否仍然匹配 thread 的 URI
|
|
280
|
+
// 防止用户快速滚动时 widget 渲染到错误的文件中
|
|
281
|
+
if (widget && editor.currentUri?.isEqual(this.uri)) {
|
|
282
|
+
widget.show();
|
|
283
|
+
}
|
|
284
|
+
// 执行完成后从跟踪集合中移除
|
|
285
|
+
this.pendingShowTimeouts.delete(timeout);
|
|
286
|
+
}, 100);
|
|
287
|
+
this.pendingShowTimeouts.add(timeout);
|
|
258
288
|
}
|
|
259
289
|
}
|
|
260
290
|
}
|
|
@@ -206,10 +206,15 @@ export class CommentsZoneWidget extends ResizeZoneWidget implements ICommentsZon
|
|
|
206
206
|
</ConfigProvider>,
|
|
207
207
|
);
|
|
208
208
|
|
|
209
|
+
const disposer = editor.monacoEditor.onDidChangeModel(() => {
|
|
210
|
+
thread.hide();
|
|
211
|
+
});
|
|
212
|
+
|
|
209
213
|
this.addDispose({
|
|
210
214
|
dispose: () => {
|
|
211
215
|
this.wrapperRoot?.unmount();
|
|
212
216
|
this.wrapperRoot = undefined;
|
|
217
|
+
disposer.dispose();
|
|
213
218
|
},
|
|
214
219
|
});
|
|
215
220
|
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
localize,
|
|
19
19
|
memoize,
|
|
20
20
|
} from '@opensumi/ide-core-browser';
|
|
21
|
-
import { IEditor } from '@opensumi/ide-editor';
|
|
21
|
+
import { EditorCollectionService, IEditor } from '@opensumi/ide-editor';
|
|
22
22
|
import {
|
|
23
23
|
IEditorDecorationCollectionService,
|
|
24
24
|
IEditorDocumentModelService,
|
|
@@ -77,6 +77,9 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
77
77
|
@Autowired(WorkbenchEditorService)
|
|
78
78
|
private readonly workbenchEditorService: WorkbenchEditorService;
|
|
79
79
|
|
|
80
|
+
@Autowired(EditorCollectionService)
|
|
81
|
+
private readonly editorCollectionService: EditorCollectionService;
|
|
82
|
+
|
|
80
83
|
@Autowired(ResourceService)
|
|
81
84
|
private readonly resourceService: ResourceService;
|
|
82
85
|
|
|
@@ -106,6 +109,8 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
106
109
|
|
|
107
110
|
private decorationProviderDisposer = Disposable.NULL;
|
|
108
111
|
|
|
112
|
+
private editorRenderAbortControllers = new Map<string, AbortController>();
|
|
113
|
+
|
|
109
114
|
get commentsThreads() {
|
|
110
115
|
return [...this.threads.values()];
|
|
111
116
|
}
|
|
@@ -300,10 +305,27 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
300
305
|
return this.editor;
|
|
301
306
|
}
|
|
302
307
|
|
|
308
|
+
private editorDisposerMap = new Map<string, Disposable>();
|
|
309
|
+
|
|
303
310
|
public handleOnCreateEditor(editor: IEditor) {
|
|
311
|
+
const disposer = new Disposable();
|
|
312
|
+
if (this.allEditors.some((e) => e.monacoEditor.getId() === editor.monacoEditor.getId())) {
|
|
313
|
+
return this.editorDisposerMap.get(editor.monacoEditor.getId()) || disposer;
|
|
314
|
+
}
|
|
315
|
+
this.editorDisposerMap.set(editor.monacoEditor.getId(), disposer);
|
|
304
316
|
this.allEditors.push(editor);
|
|
317
|
+
|
|
318
|
+
disposer.addDispose(
|
|
319
|
+
Disposable.create(() => {
|
|
320
|
+
const controller = this.editorRenderAbortControllers.get(editor.getId());
|
|
321
|
+
if (controller) {
|
|
322
|
+
controller.abort();
|
|
323
|
+
this.editorRenderAbortControllers.delete(editor.getId());
|
|
324
|
+
}
|
|
325
|
+
}),
|
|
326
|
+
);
|
|
327
|
+
|
|
305
328
|
this.editor = editor;
|
|
306
|
-
const disposer = new Disposable();
|
|
307
329
|
let commentRangeDecorationIds: string[] = [];
|
|
308
330
|
let hasHiddenArea = false;
|
|
309
331
|
|
|
@@ -507,9 +529,17 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
507
529
|
this.tryUpdateReservedSpace(editor);
|
|
508
530
|
|
|
509
531
|
disposer.addDispose(
|
|
510
|
-
editor.monacoEditor.onDidChangeModel(() => {
|
|
511
|
-
|
|
512
|
-
|
|
532
|
+
editor.monacoEditor.onDidChangeModel((event) => {
|
|
533
|
+
const { newModelUrl } = event;
|
|
534
|
+
if (newModelUrl) {
|
|
535
|
+
const currentMultiDiffEditor = this.editorCollectionService.listMultiDiffEditors()[0];
|
|
536
|
+
if (currentMultiDiffEditor) {
|
|
537
|
+
editor.updateDocumentModel?.(URI.from(newModelUrl));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
this.renderCommentRange(editor).then(() => {
|
|
541
|
+
this.tryUpdateReservedSpace(editor);
|
|
542
|
+
});
|
|
513
543
|
}),
|
|
514
544
|
);
|
|
515
545
|
return disposer;
|
|
@@ -560,7 +590,7 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
560
590
|
}
|
|
561
591
|
}
|
|
562
592
|
|
|
563
|
-
private
|
|
593
|
+
private tryUpdateReservedSpace(editor: IEditor) {
|
|
564
594
|
if (!editor) {
|
|
565
595
|
return;
|
|
566
596
|
}
|
|
@@ -661,125 +691,73 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
661
691
|
if (!editor.currentUri) {
|
|
662
692
|
return;
|
|
663
693
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
startColumn: selection.startColumn,
|
|
699
|
-
endColumn: contributionRange.endColumn,
|
|
700
|
-
};
|
|
701
|
-
const topCommentRange = {
|
|
702
|
-
startLineNumber: contributionRange.startLineNumber,
|
|
703
|
-
endLineNumber: selectionRange.startLineNumber - 1,
|
|
704
|
-
startColumn: contributionRange.startColumn,
|
|
705
|
-
endColumn: selectionRange.endColumn,
|
|
706
|
-
};
|
|
694
|
+
|
|
695
|
+
const prevController = this.editorRenderAbortControllers.get(editor.getId());
|
|
696
|
+
if (prevController) {
|
|
697
|
+
prevController.abort();
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const controller = new AbortController();
|
|
701
|
+
this.editorRenderAbortControllers.set(editor.getId(), controller);
|
|
702
|
+
|
|
703
|
+
try {
|
|
704
|
+
const contributionRanges = await this.getContributionRanges(editor.currentUri);
|
|
705
|
+
if (controller.signal.aborted) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if (contributionRanges.length > 0) {
|
|
710
|
+
const newDecorations: {
|
|
711
|
+
range: IRange;
|
|
712
|
+
options: monaco.editor.IModelDecorationOptions;
|
|
713
|
+
}[] = [];
|
|
714
|
+
contributionRanges.map((contributionRange) => {
|
|
715
|
+
// Check if operation was cancelled
|
|
716
|
+
if (controller.signal.aborted) {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
if (selection.startLineNumber === 0 && selection.endLineNumber === 0) {
|
|
720
|
+
newDecorations.push({
|
|
721
|
+
range: contributionRange,
|
|
722
|
+
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
723
|
+
});
|
|
724
|
+
} else if (
|
|
725
|
+
selection.startLineNumber <= contributionRange.startLineNumber &&
|
|
726
|
+
selection.endLineNumber >= contributionRange.endLineNumber
|
|
727
|
+
) {
|
|
707
728
|
newDecorations.push(
|
|
708
729
|
...[
|
|
709
730
|
{
|
|
710
|
-
range:
|
|
711
|
-
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
range: selectionRange,
|
|
731
|
+
range: contributionRange,
|
|
715
732
|
options: this.createDottedRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
716
733
|
},
|
|
717
734
|
{
|
|
718
|
-
range:
|
|
735
|
+
range: contributionRange,
|
|
719
736
|
options: this.createThreadRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
720
737
|
},
|
|
721
738
|
],
|
|
722
739
|
);
|
|
723
|
-
} else {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
} else if (selection.endLineNumber < contributionRange.endLineNumber) {
|
|
730
|
-
if (selection.endLineNumber >= contributionRange.startLineNumber) {
|
|
731
|
-
// 存在交集
|
|
732
|
-
if (selection.startLineNumber >= contributionRange.startLineNumber) {
|
|
733
|
-
const topCommentRange = {
|
|
734
|
-
startLineNumber: contributionRange.startLineNumber,
|
|
735
|
-
startColumn: contributionRange.startColumn,
|
|
736
|
-
endLineNumber: selection.startLineNumber - 1,
|
|
737
|
-
endColumn: selection.startColumn,
|
|
738
|
-
};
|
|
739
|
-
const bottomCommentRange = {
|
|
740
|
-
startLineNumber: selection.endLineNumber + 1,
|
|
741
|
-
startColumn: selection.endColumn,
|
|
740
|
+
} else if (selection.endLineNumber >= contributionRange.endLineNumber) {
|
|
741
|
+
if (selection.startLineNumber <= contributionRange.endLineNumber) {
|
|
742
|
+
// 存在交集
|
|
743
|
+
const selectionRange = {
|
|
744
|
+
startLineNumber: selection.startLineNumber,
|
|
742
745
|
endLineNumber: contributionRange.endLineNumber,
|
|
743
|
-
|
|
746
|
+
startColumn: selection.startColumn,
|
|
747
|
+
endColumn: selection.endColumn,
|
|
744
748
|
};
|
|
745
|
-
const
|
|
746
|
-
selection.startLineNumber !== contributionRange.startLineNumber
|
|
747
|
-
? [
|
|
748
|
-
{
|
|
749
|
-
range: topCommentRange,
|
|
750
|
-
options:
|
|
751
|
-
this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
752
|
-
},
|
|
753
|
-
]
|
|
754
|
-
: [];
|
|
755
|
-
decorations.push({
|
|
756
|
-
range: selection,
|
|
757
|
-
options: this.createDottedRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
758
|
-
});
|
|
759
|
-
decorations.push({
|
|
760
|
-
range: selection,
|
|
761
|
-
options: this.createThreadRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
762
|
-
});
|
|
763
|
-
decorations.push({
|
|
764
|
-
range: bottomCommentRange,
|
|
765
|
-
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
766
|
-
});
|
|
767
|
-
newDecorations.push(...decorations);
|
|
768
|
-
} else {
|
|
769
|
-
const selectionRange = {
|
|
749
|
+
const topCommentRange = {
|
|
770
750
|
startLineNumber: contributionRange.startLineNumber,
|
|
751
|
+
endLineNumber: selectionRange.startLineNumber - 1,
|
|
771
752
|
startColumn: contributionRange.startColumn,
|
|
772
|
-
|
|
773
|
-
endColumn: selection.endColumn,
|
|
774
|
-
};
|
|
775
|
-
const bottomCommentRange = {
|
|
776
|
-
startLineNumber: selectionRange.endLineNumber + 1,
|
|
777
|
-
startColumn: selectionRange.endColumn,
|
|
778
|
-
endLineNumber: contributionRange.endLineNumber,
|
|
779
|
-
endColumn: contributionRange.endColumn,
|
|
753
|
+
endColumn: selectionRange.endColumn,
|
|
780
754
|
};
|
|
781
755
|
newDecorations.push(
|
|
782
756
|
...[
|
|
757
|
+
{
|
|
758
|
+
range: topCommentRange,
|
|
759
|
+
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
760
|
+
},
|
|
783
761
|
{
|
|
784
762
|
range: selectionRange,
|
|
785
763
|
options: this.createDottedRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
@@ -788,28 +766,108 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
788
766
|
range: selectionRange,
|
|
789
767
|
options: this.createThreadRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
790
768
|
},
|
|
791
|
-
{
|
|
792
|
-
range: bottomCommentRange,
|
|
793
|
-
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
794
|
-
},
|
|
795
769
|
],
|
|
796
770
|
);
|
|
771
|
+
} else {
|
|
772
|
+
newDecorations.push({
|
|
773
|
+
range: contributionRange,
|
|
774
|
+
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
} else if (selection.endLineNumber < contributionRange.endLineNumber) {
|
|
778
|
+
if (selection.endLineNumber >= contributionRange.startLineNumber) {
|
|
779
|
+
// 存在交集
|
|
780
|
+
if (selection.startLineNumber >= contributionRange.startLineNumber) {
|
|
781
|
+
const topCommentRange = {
|
|
782
|
+
startLineNumber: contributionRange.startLineNumber,
|
|
783
|
+
startColumn: contributionRange.startColumn,
|
|
784
|
+
endLineNumber: selection.startLineNumber - 1,
|
|
785
|
+
endColumn: selection.startColumn,
|
|
786
|
+
};
|
|
787
|
+
const bottomCommentRange = {
|
|
788
|
+
startLineNumber: selection.endLineNumber + 1,
|
|
789
|
+
startColumn: selection.endColumn,
|
|
790
|
+
endLineNumber: contributionRange.endLineNumber,
|
|
791
|
+
endColumn: contributionRange.endColumn,
|
|
792
|
+
};
|
|
793
|
+
const decorations =
|
|
794
|
+
selection.startLineNumber !== contributionRange.startLineNumber
|
|
795
|
+
? [
|
|
796
|
+
{
|
|
797
|
+
range: topCommentRange,
|
|
798
|
+
options:
|
|
799
|
+
this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
800
|
+
},
|
|
801
|
+
]
|
|
802
|
+
: [];
|
|
803
|
+
decorations.push({
|
|
804
|
+
range: selection,
|
|
805
|
+
options: this.createDottedRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
806
|
+
});
|
|
807
|
+
decorations.push({
|
|
808
|
+
range: selection,
|
|
809
|
+
options: this.createThreadRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
810
|
+
});
|
|
811
|
+
decorations.push({
|
|
812
|
+
range: bottomCommentRange,
|
|
813
|
+
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
814
|
+
});
|
|
815
|
+
newDecorations.push(...decorations);
|
|
816
|
+
} else {
|
|
817
|
+
const selectionRange = {
|
|
818
|
+
startLineNumber: contributionRange.startLineNumber,
|
|
819
|
+
startColumn: contributionRange.startColumn,
|
|
820
|
+
endLineNumber: selection.endLineNumber,
|
|
821
|
+
endColumn: selection.endColumn,
|
|
822
|
+
};
|
|
823
|
+
const bottomCommentRange = {
|
|
824
|
+
startLineNumber: selectionRange.endLineNumber + 1,
|
|
825
|
+
startColumn: selectionRange.endColumn,
|
|
826
|
+
endLineNumber: contributionRange.endLineNumber,
|
|
827
|
+
endColumn: contributionRange.endColumn,
|
|
828
|
+
};
|
|
829
|
+
newDecorations.push(
|
|
830
|
+
...[
|
|
831
|
+
{
|
|
832
|
+
range: selectionRange,
|
|
833
|
+
options: this.createDottedRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
range: selectionRange,
|
|
837
|
+
options: this.createThreadRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
range: bottomCommentRange,
|
|
841
|
+
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
842
|
+
},
|
|
843
|
+
],
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
} else {
|
|
847
|
+
newDecorations.push({
|
|
848
|
+
range: contributionRange,
|
|
849
|
+
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
850
|
+
});
|
|
797
851
|
}
|
|
798
|
-
} else {
|
|
799
|
-
newDecorations.push({
|
|
800
|
-
range: contributionRange,
|
|
801
|
-
options: this.createCommentRangeDecoration() as unknown as monaco.editor.IModelDecorationOptions,
|
|
802
|
-
});
|
|
803
852
|
}
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
if (controller.signal.aborted) {
|
|
856
|
+
return;
|
|
804
857
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
858
|
+
|
|
859
|
+
const commentRangeDecorationIds = this.commentRangeDecorationMap.get(editor.currentUri.toString()) || [];
|
|
860
|
+
this.commentRangeDecorationMap.set(
|
|
861
|
+
editor.currentUri.toString(),
|
|
862
|
+
editor.monacoEditor.deltaDecorations(commentRangeDecorationIds, newDecorations),
|
|
863
|
+
);
|
|
864
|
+
} else {
|
|
865
|
+
this.commentRangeDecorationMap.set(editor.currentUri.toString(), []);
|
|
866
|
+
}
|
|
867
|
+
} finally {
|
|
868
|
+
if (this.editorRenderAbortControllers.get(editor.getId()) === controller) {
|
|
869
|
+
this.editorRenderAbortControllers.delete(editor.getId());
|
|
870
|
+
}
|
|
813
871
|
}
|
|
814
872
|
}
|
|
815
873
|
|
|
@@ -1012,8 +1070,8 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
1012
1070
|
}
|
|
1013
1071
|
|
|
1014
1072
|
private registerDecorationProvider() {
|
|
1015
|
-
// dispose 掉上一个 decorationProvider
|
|
1016
1073
|
this.decorationProviderDisposer.dispose();
|
|
1074
|
+
// 该逻辑仅在非平铺模式的 DiffEditor 中生效,当平铺模式时,会同时存在多个可见的 editor,所以需要单独处理
|
|
1017
1075
|
this.decorationProviderDisposer = this.editorDecorationCollectionService.registerDecorationProvider({
|
|
1018
1076
|
schemes: [...this.shouldShowCommentsSchemes.values()],
|
|
1019
1077
|
key: 'comments',
|
|
@@ -1021,23 +1079,23 @@ export class CommentsService extends Disposable implements ICommentsService {
|
|
|
1021
1079
|
provideEditorDecoration: (uri: URI) =>
|
|
1022
1080
|
this.commentsThreads
|
|
1023
1081
|
.map((thread) => {
|
|
1024
|
-
if (thread.uri.
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
thread.
|
|
1082
|
+
if (thread.uri.isEqual(uri)) {
|
|
1083
|
+
const editor = this.editorCollectionService.getEditorByUri(thread.uri);
|
|
1084
|
+
if (editor) {
|
|
1085
|
+
thread.show(editor);
|
|
1086
|
+
} else {
|
|
1087
|
+
thread.hide();
|
|
1028
1088
|
}
|
|
1029
1089
|
} else {
|
|
1030
|
-
// 临时隐藏,当切回来时会恢复
|
|
1031
1090
|
thread.hide();
|
|
1032
1091
|
}
|
|
1033
1092
|
return thread;
|
|
1034
1093
|
})
|
|
1035
1094
|
.filter((thread) => {
|
|
1036
1095
|
const isCurrentThread = thread.uri.isEqual(uri);
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
return isCurrentThread;
|
|
1096
|
+
return this.filterThreadDecoration
|
|
1097
|
+
? isCurrentThread && this.filterThreadDecoration(thread)
|
|
1098
|
+
: isCurrentThread;
|
|
1041
1099
|
})
|
|
1042
1100
|
.map((thread) => ({
|
|
1043
1101
|
range: {
|
package/src/common/index.ts
CHANGED
|
@@ -540,6 +540,10 @@ export interface ICommentsThread extends IDisposable {
|
|
|
540
540
|
* 如果之前是显示的状态,则恢复显示
|
|
541
541
|
*/
|
|
542
542
|
showWidgetsIfShowed(): void;
|
|
543
|
+
/**
|
|
544
|
+
* 移除即将显示的 widget,避免竞态条件
|
|
545
|
+
*/
|
|
546
|
+
removePaddingShowedWidgets(): void;
|
|
543
547
|
/**
|
|
544
548
|
* 临时隐藏 wiget,restoreShow 时恢复
|
|
545
549
|
*/
|