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