@codingame/monaco-vscode-api 2.1.4 → 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 +2 -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/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,16 @@
|
|
|
1
|
+
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';
|
|
2
|
+
import { Registry } from '../../../../platform/registry/common/platform.js';
|
|
3
|
+
import { EditorPaneDescriptor } from '../../../browser/editor.js';
|
|
4
|
+
import { Extensions } from '../../../common/contributions.js';
|
|
5
|
+
import { EditorExtensions } from '../../../common/editor.js';
|
|
6
|
+
import { CustomEditorInputSerializer, ComplexCustomWorkingCopyEditorHandler } from './customEditorInputFactory.js';
|
|
7
|
+
import { WebviewEditor } from '../../webviewPanel/browser/webviewEditor.js';
|
|
8
|
+
import { CustomEditorInput } from './customEditorInput.js';
|
|
9
|
+
( Registry.as(EditorExtensions.EditorPane))
|
|
10
|
+
.registerEditorPane(EditorPaneDescriptor.create(WebviewEditor, WebviewEditor.ID, 'Webview Editor'), [
|
|
11
|
+
( new SyncDescriptor(CustomEditorInput))
|
|
12
|
+
]);
|
|
13
|
+
( Registry.as(EditorExtensions.EditorFactory))
|
|
14
|
+
.registerEditorSerializer(CustomEditorInputSerializer.ID, CustomEditorInputSerializer);
|
|
15
|
+
( Registry.as(Extensions.Workbench))
|
|
16
|
+
.registerWorkbenchContribution(ComplexCustomWorkingCopyEditorHandler, 1 );
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Disposable } from '../../../../base/common/lifecycle.js';
|
|
3
|
+
import { Schemas } from '../../../../base/common/network.js';
|
|
4
|
+
import { isEqual } from '../../../../base/common/resources.js';
|
|
5
|
+
import { URI } from '../../../../base/common/uri.js';
|
|
6
|
+
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
|
|
7
|
+
import { CustomEditorInput } from './customEditorInput.js';
|
|
8
|
+
import { ICustomEditorService } from '../common/customEditor.js';
|
|
9
|
+
import { NotebookEditorInput } from '../../notebook/common/notebookEditorInput.js';
|
|
10
|
+
import { IWebviewService } from '../../webview/browser/webview.js';
|
|
11
|
+
import { WebviewEditorInputSerializer, restoreWebviewOptions, restoreWebviewContentOptions, reviveWebviewExtensionDescription } from '../../webviewPanel/browser/webviewEditorInputSerializer.js';
|
|
12
|
+
import { IWebviewWorkbenchService } from '../../webviewPanel/browser/webviewWorkbenchService.js';
|
|
13
|
+
import { IWorkingCopyBackupService } from '../../../services/workingCopy/common/workingCopyBackup.js';
|
|
14
|
+
import { IWorkingCopyEditorService } from '../../../services/workingCopy/common/workingCopyEditorService.js';
|
|
15
|
+
let CustomEditorInputSerializer = class CustomEditorInputSerializer extends WebviewEditorInputSerializer {
|
|
16
|
+
static { this.ID = CustomEditorInput.typeId; }
|
|
17
|
+
constructor(webviewWorkbenchService, _instantiationService, _webviewService) {
|
|
18
|
+
super(webviewWorkbenchService);
|
|
19
|
+
this._instantiationService = _instantiationService;
|
|
20
|
+
this._webviewService = _webviewService;
|
|
21
|
+
}
|
|
22
|
+
serialize(input) {
|
|
23
|
+
const dirty = input.isDirty();
|
|
24
|
+
const data = {
|
|
25
|
+
...this.toJson(input),
|
|
26
|
+
editorResource: input.resource.toJSON(),
|
|
27
|
+
dirty,
|
|
28
|
+
backupId: dirty ? input.backupId : undefined,
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
return JSON.stringify(data);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
fromJson(data) {
|
|
38
|
+
return {
|
|
39
|
+
...super.fromJson(data),
|
|
40
|
+
editorResource: ( URI.from(data.editorResource)),
|
|
41
|
+
dirty: data.dirty,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
deserialize(_instantiationService, serializedEditorInput) {
|
|
45
|
+
const data = this.fromJson(JSON.parse(serializedEditorInput));
|
|
46
|
+
const webview = reviveWebview(this._webviewService, data);
|
|
47
|
+
const customInput = this._instantiationService.createInstance(CustomEditorInput, { resource: data.editorResource, viewType: data.viewType }, webview, { startsDirty: data.dirty, backupId: data.backupId });
|
|
48
|
+
if (typeof data.group === 'number') {
|
|
49
|
+
customInput.updateGroup(data.group);
|
|
50
|
+
}
|
|
51
|
+
return customInput;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
CustomEditorInputSerializer = ( __decorate([
|
|
55
|
+
( __param(0, IWebviewWorkbenchService)),
|
|
56
|
+
( __param(1, IInstantiationService)),
|
|
57
|
+
( __param(2, IWebviewService))
|
|
58
|
+
], CustomEditorInputSerializer));
|
|
59
|
+
function reviveWebview(webviewService, data) {
|
|
60
|
+
const webview = webviewService.createWebviewOverlay({
|
|
61
|
+
providedViewType: data.viewType,
|
|
62
|
+
origin: data.origin,
|
|
63
|
+
title: undefined,
|
|
64
|
+
options: {
|
|
65
|
+
purpose: "customEditor" ,
|
|
66
|
+
enableFindWidget: data.webviewOptions.enableFindWidget,
|
|
67
|
+
retainContextWhenHidden: data.webviewOptions.retainContextWhenHidden,
|
|
68
|
+
},
|
|
69
|
+
contentOptions: data.contentOptions,
|
|
70
|
+
extension: data.extension,
|
|
71
|
+
});
|
|
72
|
+
webview.state = data.state;
|
|
73
|
+
return webview;
|
|
74
|
+
}
|
|
75
|
+
let ComplexCustomWorkingCopyEditorHandler = class ComplexCustomWorkingCopyEditorHandler extends Disposable {
|
|
76
|
+
constructor(_instantiationService, _workingCopyEditorService, _workingCopyBackupService, _webviewService, _customEditorService
|
|
77
|
+
) {
|
|
78
|
+
super();
|
|
79
|
+
this._instantiationService = _instantiationService;
|
|
80
|
+
this._workingCopyBackupService = _workingCopyBackupService;
|
|
81
|
+
this._webviewService = _webviewService;
|
|
82
|
+
this._register(_workingCopyEditorService.registerHandler(this));
|
|
83
|
+
}
|
|
84
|
+
handles(workingCopy) {
|
|
85
|
+
return workingCopy.resource.scheme === Schemas.vscodeCustomEditor;
|
|
86
|
+
}
|
|
87
|
+
isOpen(workingCopy, editor) {
|
|
88
|
+
if (!this.handles(workingCopy)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (workingCopy.resource.authority === 'jupyter-notebook-ipynb' && editor instanceof NotebookEditorInput) {
|
|
92
|
+
try {
|
|
93
|
+
const data = JSON.parse(workingCopy.resource.query);
|
|
94
|
+
const workingCopyResource = ( URI.from(data));
|
|
95
|
+
return isEqual(workingCopyResource, editor.resource);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!(editor instanceof CustomEditorInput)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (workingCopy.resource.authority !== editor.viewType.replace(/[^a-z0-9\-_]/gi, '-').toLowerCase()) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const data = JSON.parse(workingCopy.resource.query);
|
|
109
|
+
const workingCopyResource = ( URI.from(data));
|
|
110
|
+
return isEqual(workingCopyResource, editor.resource);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async createEditor(workingCopy) {
|
|
117
|
+
const backup = await this._workingCopyBackupService.resolve(workingCopy);
|
|
118
|
+
if (!backup?.meta) {
|
|
119
|
+
throw new Error(`No backup found for custom editor: ${workingCopy.resource}`);
|
|
120
|
+
}
|
|
121
|
+
const backupData = backup.meta;
|
|
122
|
+
const extension = reviveWebviewExtensionDescription(backupData.extension?.id, backupData.extension?.location);
|
|
123
|
+
const webview = reviveWebview(this._webviewService, {
|
|
124
|
+
viewType: backupData.viewType,
|
|
125
|
+
origin: backupData.webview.origin,
|
|
126
|
+
webviewOptions: restoreWebviewOptions(backupData.webview.options),
|
|
127
|
+
contentOptions: restoreWebviewContentOptions(backupData.webview.options),
|
|
128
|
+
state: backupData.webview.state,
|
|
129
|
+
extension,
|
|
130
|
+
});
|
|
131
|
+
const editor = this._instantiationService.createInstance(CustomEditorInput, { resource: URI.revive(backupData.editorResource), viewType: backupData.viewType }, webview, { backupId: backupData.backupId });
|
|
132
|
+
editor.updateGroup(0);
|
|
133
|
+
return editor;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
ComplexCustomWorkingCopyEditorHandler = ( __decorate([
|
|
137
|
+
( __param(0, IInstantiationService)),
|
|
138
|
+
( __param(1, IWorkingCopyEditorService)),
|
|
139
|
+
( __param(2, IWorkingCopyBackupService)),
|
|
140
|
+
( __param(3, IWebviewService)),
|
|
141
|
+
( __param(4, ICustomEditorService))
|
|
142
|
+
], ComplexCustomWorkingCopyEditorHandler));
|
|
143
|
+
export { ComplexCustomWorkingCopyEditorHandler, CustomEditorInputSerializer };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import './media/customEditor.css.js';
|
|
3
|
+
import { coalesce } from '../../../../base/common/arrays.js';
|
|
4
|
+
import { Emitter } from '../../../../base/common/event.js';
|
|
5
|
+
import { Disposable, DisposableStore, toDisposable } from '../../../../base/common/lifecycle.js';
|
|
6
|
+
import { Schemas } from '../../../../base/common/network.js';
|
|
7
|
+
import { extname, isEqual } from '../../../../base/common/resources.js';
|
|
8
|
+
import { assertIsDefined } from '../../../../base/common/types.js';
|
|
9
|
+
import { URI } from '../../../../base/common/uri.js';
|
|
10
|
+
import { UndoCommand, RedoCommand } from '../../../../editor/browser/editorExtensions.js';
|
|
11
|
+
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
|
|
12
|
+
import { IFileService } from '../../../../platform/files/common/files.js';
|
|
13
|
+
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
|
|
14
|
+
import { Registry } from '../../../../platform/registry/common/platform.js';
|
|
15
|
+
import { IStorageService } from '../../../../platform/storage/common/storage.js';
|
|
16
|
+
import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js';
|
|
17
|
+
import { EditorExtensions, DEFAULT_EDITOR_ASSOCIATION } from '../../../common/editor.js';
|
|
18
|
+
import { DiffEditorInput } from '../../../common/editor/diffEditorInput.js';
|
|
19
|
+
import { CONTEXT_ACTIVE_CUSTOM_EDITOR_ID, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorInfoCollection } from '../common/customEditor.js';
|
|
20
|
+
import { CustomEditorModelManager } from '../common/customEditorModelManager.js';
|
|
21
|
+
import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js';
|
|
22
|
+
import { RegisteredEditorPriority, IEditorResolverService } from '../../../services/editor/common/editorResolverService.js';
|
|
23
|
+
import { IEditorService } from '../../../services/editor/common/editorService.js';
|
|
24
|
+
import { ContributedCustomEditors } from '../common/contributedCustomEditors.js';
|
|
25
|
+
import { CustomEditorInput } from './customEditorInput.js';
|
|
26
|
+
let CustomEditorService = class CustomEditorService extends Disposable {
|
|
27
|
+
constructor(contextKeyService, fileService, storageService, editorService, editorGroupService, instantiationService, uriIdentityService, editorResolverService) {
|
|
28
|
+
super();
|
|
29
|
+
this.editorService = editorService;
|
|
30
|
+
this.editorGroupService = editorGroupService;
|
|
31
|
+
this.instantiationService = instantiationService;
|
|
32
|
+
this.uriIdentityService = uriIdentityService;
|
|
33
|
+
this.editorResolverService = editorResolverService;
|
|
34
|
+
this._untitledCounter = 0;
|
|
35
|
+
this._editorResolverDisposables = this._register(( new DisposableStore()));
|
|
36
|
+
this._editorCapabilities = ( new Map());
|
|
37
|
+
this._models = ( new CustomEditorModelManager());
|
|
38
|
+
this._onDidChangeEditorTypes = this._register(( new Emitter()));
|
|
39
|
+
this.onDidChangeEditorTypes = this._onDidChangeEditorTypes.event;
|
|
40
|
+
this._fileEditorFactory = ( Registry.as(EditorExtensions.EditorFactory)).getFileEditorFactory();
|
|
41
|
+
this._activeCustomEditorId = CONTEXT_ACTIVE_CUSTOM_EDITOR_ID.bindTo(contextKeyService);
|
|
42
|
+
this._focusedCustomEditorIsEditable = CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE.bindTo(contextKeyService);
|
|
43
|
+
this._contributedEditors = this._register(( new ContributedCustomEditors(storageService)));
|
|
44
|
+
this.editorResolverService.bufferChangeEvents(this.registerContributionPoints.bind(this));
|
|
45
|
+
this._register(this._contributedEditors.onChange(() => {
|
|
46
|
+
this.editorResolverService.bufferChangeEvents(this.registerContributionPoints.bind(this));
|
|
47
|
+
this.updateContexts();
|
|
48
|
+
this._onDidChangeEditorTypes.fire();
|
|
49
|
+
}));
|
|
50
|
+
this._register(this.editorService.onDidActiveEditorChange(() => this.updateContexts()));
|
|
51
|
+
this._register(fileService.onDidRunOperation(e => {
|
|
52
|
+
if (e.isOperation(2 )) {
|
|
53
|
+
this.handleMovedFileInOpenedFileEditors(e.resource, this.uriIdentityService.asCanonicalUri(e.target.resource));
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
const PRIORITY = 105;
|
|
57
|
+
this._register(UndoCommand.addImplementation(PRIORITY, 'custom-editor', () => {
|
|
58
|
+
return this.withActiveCustomEditor(editor => editor.undo());
|
|
59
|
+
}));
|
|
60
|
+
this._register(RedoCommand.addImplementation(PRIORITY, 'custom-editor', () => {
|
|
61
|
+
return this.withActiveCustomEditor(editor => editor.redo());
|
|
62
|
+
}));
|
|
63
|
+
this.updateContexts();
|
|
64
|
+
}
|
|
65
|
+
getEditorTypes() {
|
|
66
|
+
return [...this._contributedEditors];
|
|
67
|
+
}
|
|
68
|
+
withActiveCustomEditor(f) {
|
|
69
|
+
const activeEditor = this.editorService.activeEditor;
|
|
70
|
+
if (activeEditor instanceof CustomEditorInput) {
|
|
71
|
+
const result = f(activeEditor);
|
|
72
|
+
if (result) {
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
registerContributionPoints() {
|
|
80
|
+
this._editorResolverDisposables.clear();
|
|
81
|
+
for (const contributedEditor of this._contributedEditors) {
|
|
82
|
+
for (const globPattern of contributedEditor.selector) {
|
|
83
|
+
if (!globPattern.filenamePattern) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
this._editorResolverDisposables.add(this.editorResolverService.registerEditor(globPattern.filenamePattern, {
|
|
87
|
+
id: contributedEditor.id,
|
|
88
|
+
label: contributedEditor.displayName,
|
|
89
|
+
detail: contributedEditor.providerDisplayName,
|
|
90
|
+
priority: contributedEditor.priority,
|
|
91
|
+
}, {
|
|
92
|
+
singlePerResource: () => !this.getCustomEditorCapabilities(contributedEditor.id)?.supportsMultipleEditorsPerDocument ?? true
|
|
93
|
+
}, {
|
|
94
|
+
createEditorInput: ({ resource }, group) => {
|
|
95
|
+
return { editor: CustomEditorInput.create(this.instantiationService, resource, contributedEditor.id, group.id) };
|
|
96
|
+
},
|
|
97
|
+
createUntitledEditorInput: ({ resource }, group) => {
|
|
98
|
+
return { editor: CustomEditorInput.create(this.instantiationService, resource ?? ( URI.from(
|
|
99
|
+
{ scheme: Schemas.untitled, authority: `Untitled-${this._untitledCounter++}` }
|
|
100
|
+
)), contributedEditor.id, group.id) };
|
|
101
|
+
},
|
|
102
|
+
createDiffEditorInput: (diffEditorInput, group) => {
|
|
103
|
+
return { editor: this.createDiffEditorInput(diffEditorInput, contributedEditor.id, group) };
|
|
104
|
+
},
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
createDiffEditorInput(editor, editorID, group) {
|
|
110
|
+
const modifiedOverride = CustomEditorInput.create(this.instantiationService, assertIsDefined(editor.modified.resource), editorID, group.id, { customClasses: 'modified' });
|
|
111
|
+
const originalOverride = CustomEditorInput.create(this.instantiationService, assertIsDefined(editor.original.resource), editorID, group.id, { customClasses: 'original' });
|
|
112
|
+
return this.instantiationService.createInstance(DiffEditorInput, editor.label, editor.description, originalOverride, modifiedOverride, true);
|
|
113
|
+
}
|
|
114
|
+
get models() { return this._models; }
|
|
115
|
+
getCustomEditor(viewType) {
|
|
116
|
+
return this._contributedEditors.get(viewType);
|
|
117
|
+
}
|
|
118
|
+
getContributedCustomEditors(resource) {
|
|
119
|
+
return ( new CustomEditorInfoCollection(this._contributedEditors.getContributedEditors(resource)));
|
|
120
|
+
}
|
|
121
|
+
getUserConfiguredCustomEditors(resource) {
|
|
122
|
+
const resourceAssocations = this.editorResolverService.getAssociationsForResource(resource);
|
|
123
|
+
return ( new CustomEditorInfoCollection(coalesce(( resourceAssocations
|
|
124
|
+
.map(association => this._contributedEditors.get(association.viewType))))));
|
|
125
|
+
}
|
|
126
|
+
getAllCustomEditors(resource) {
|
|
127
|
+
return ( new CustomEditorInfoCollection([
|
|
128
|
+
...this.getUserConfiguredCustomEditors(resource).allEditors,
|
|
129
|
+
...this.getContributedCustomEditors(resource).allEditors,
|
|
130
|
+
]));
|
|
131
|
+
}
|
|
132
|
+
registerCustomEditorCapabilities(viewType, options) {
|
|
133
|
+
if (( this._editorCapabilities.has(viewType))) {
|
|
134
|
+
throw new Error(`Capabilities for ${viewType} already set`);
|
|
135
|
+
}
|
|
136
|
+
this._editorCapabilities.set(viewType, options);
|
|
137
|
+
return toDisposable(() => {
|
|
138
|
+
this._editorCapabilities.delete(viewType);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
getCustomEditorCapabilities(viewType) {
|
|
142
|
+
return this._editorCapabilities.get(viewType);
|
|
143
|
+
}
|
|
144
|
+
updateContexts() {
|
|
145
|
+
const activeEditorPane = this.editorService.activeEditorPane;
|
|
146
|
+
const resource = activeEditorPane?.input?.resource;
|
|
147
|
+
if (!resource) {
|
|
148
|
+
this._activeCustomEditorId.reset();
|
|
149
|
+
this._focusedCustomEditorIsEditable.reset();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this._activeCustomEditorId.set(activeEditorPane?.input instanceof CustomEditorInput ? activeEditorPane.input.viewType : '');
|
|
153
|
+
this._focusedCustomEditorIsEditable.set(activeEditorPane?.input instanceof CustomEditorInput);
|
|
154
|
+
}
|
|
155
|
+
async handleMovedFileInOpenedFileEditors(oldResource, newResource) {
|
|
156
|
+
if (extname(oldResource).toLowerCase() === extname(newResource).toLowerCase()) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const possibleEditors = this.getAllCustomEditors(newResource);
|
|
160
|
+
if (!( possibleEditors.allEditors.some(editor => editor.priority !== RegisteredEditorPriority.option))) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const editorsToReplace = ( new Map());
|
|
164
|
+
for (const group of this.editorGroupService.groups) {
|
|
165
|
+
for (const editor of group.editors) {
|
|
166
|
+
if (this._fileEditorFactory.isFileEditor(editor)
|
|
167
|
+
&& !(editor instanceof CustomEditorInput)
|
|
168
|
+
&& isEqual(editor.resource, newResource)) {
|
|
169
|
+
let entry = editorsToReplace.get(group.id);
|
|
170
|
+
if (!entry) {
|
|
171
|
+
entry = [];
|
|
172
|
+
editorsToReplace.set(group.id, entry);
|
|
173
|
+
}
|
|
174
|
+
entry.push(editor);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!editorsToReplace.size) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
for (const [group, entries] of editorsToReplace) {
|
|
182
|
+
this.editorService.replaceEditors(( entries.map(editor => {
|
|
183
|
+
let replacement;
|
|
184
|
+
if (possibleEditors.defaultEditor) {
|
|
185
|
+
const viewType = possibleEditors.defaultEditor.id;
|
|
186
|
+
replacement = CustomEditorInput.create(this.instantiationService, newResource, viewType, group);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
replacement = { resource: newResource, options: { override: DEFAULT_EDITOR_ASSOCIATION.id } };
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
editor,
|
|
193
|
+
replacement,
|
|
194
|
+
options: {
|
|
195
|
+
preserveFocus: true,
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
})), group);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
CustomEditorService = ( __decorate([
|
|
203
|
+
( __param(0, IContextKeyService)),
|
|
204
|
+
( __param(1, IFileService)),
|
|
205
|
+
( __param(2, IStorageService)),
|
|
206
|
+
( __param(3, IEditorService)),
|
|
207
|
+
( __param(4, IEditorGroupsService)),
|
|
208
|
+
( __param(5, IInstantiationService)),
|
|
209
|
+
( __param(6, IUriIdentityService)),
|
|
210
|
+
( __param(7, IEditorResolverService))
|
|
211
|
+
], CustomEditorService));
|
|
212
|
+
export { CustomEditorService };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Emitter } from '../../../../base/common/event.js';
|
|
2
|
+
import { Disposable } from '../../../../base/common/lifecycle.js';
|
|
3
|
+
import { localizeWithPath } from '../../../../nls.js';
|
|
4
|
+
import { Memento } from '../../../common/memento.js';
|
|
5
|
+
import { CustomEditorInfo } from './customEditor.js';
|
|
6
|
+
import { customEditorsExtensionPoint } from './extensionPoint.js';
|
|
7
|
+
import { RegisteredEditorPriority } from '../../../services/editor/common/editorResolverService.js';
|
|
8
|
+
class ContributedCustomEditors extends Disposable {
|
|
9
|
+
static { this.CUSTOM_EDITORS_STORAGE_ID = 'customEditors'; }
|
|
10
|
+
static { this.CUSTOM_EDITORS_ENTRY_ID = 'editors'; }
|
|
11
|
+
constructor(storageService) {
|
|
12
|
+
super();
|
|
13
|
+
this._editors = ( new Map());
|
|
14
|
+
this._onChange = this._register(( new Emitter()));
|
|
15
|
+
this.onChange = this._onChange.event;
|
|
16
|
+
this._memento = ( new Memento(ContributedCustomEditors.CUSTOM_EDITORS_STORAGE_ID, storageService));
|
|
17
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
18
|
+
for (const info of (mementoObject[ContributedCustomEditors.CUSTOM_EDITORS_ENTRY_ID] || [])) {
|
|
19
|
+
this.add(( new CustomEditorInfo(info)));
|
|
20
|
+
}
|
|
21
|
+
customEditorsExtensionPoint.setHandler(extensions => {
|
|
22
|
+
this.update(extensions);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
update(extensions) {
|
|
26
|
+
this._editors.clear();
|
|
27
|
+
for (const extension of extensions) {
|
|
28
|
+
for (const webviewEditorContribution of extension.value) {
|
|
29
|
+
this.add(( new CustomEditorInfo({
|
|
30
|
+
id: webviewEditorContribution.viewType,
|
|
31
|
+
displayName: webviewEditorContribution.displayName,
|
|
32
|
+
providerDisplayName: extension.description.isBuiltin ? ( localizeWithPath(
|
|
33
|
+
'vs/workbench/contrib/customEditor/common/contributedCustomEditors',
|
|
34
|
+
'builtinProviderDisplayName',
|
|
35
|
+
"Built-in"
|
|
36
|
+
)) : extension.description.displayName || extension.description.identifier.value,
|
|
37
|
+
selector: webviewEditorContribution.selector || [],
|
|
38
|
+
priority: getPriorityFromContribution(webviewEditorContribution, extension.description),
|
|
39
|
+
})));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
43
|
+
mementoObject[ContributedCustomEditors.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( this._editors.values()));
|
|
44
|
+
this._memento.saveMemento();
|
|
45
|
+
this._onChange.fire();
|
|
46
|
+
}
|
|
47
|
+
[Symbol.iterator]() {
|
|
48
|
+
return ( this._editors.values());
|
|
49
|
+
}
|
|
50
|
+
get(viewType) {
|
|
51
|
+
return this._editors.get(viewType);
|
|
52
|
+
}
|
|
53
|
+
getContributedEditors(resource) {
|
|
54
|
+
return Array.from(( this._editors.values()))
|
|
55
|
+
.filter(customEditor => customEditor.matches(resource));
|
|
56
|
+
}
|
|
57
|
+
add(info) {
|
|
58
|
+
if (( this._editors.has(info.id))) {
|
|
59
|
+
console.error(`Custom editor with id '${info.id}' already registered`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this._editors.set(info.id, info);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function getPriorityFromContribution(contribution, extension) {
|
|
66
|
+
switch (contribution.priority) {
|
|
67
|
+
case RegisteredEditorPriority.default:
|
|
68
|
+
case RegisteredEditorPriority.option:
|
|
69
|
+
return contribution.priority;
|
|
70
|
+
case RegisteredEditorPriority.builtin:
|
|
71
|
+
return extension.isBuiltin ? RegisteredEditorPriority.builtin : RegisteredEditorPriority.default;
|
|
72
|
+
default:
|
|
73
|
+
return RegisteredEditorPriority.default;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export { ContributedCustomEditors };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createSingleCallFunction } from '../../../../base/common/functional.js';
|
|
2
|
+
class CustomEditorModelManager {
|
|
3
|
+
constructor() {
|
|
4
|
+
this._references = ( new Map());
|
|
5
|
+
}
|
|
6
|
+
async getAllModels(resource) {
|
|
7
|
+
const keyStart = `${( resource.toString())}@@@`;
|
|
8
|
+
const models = [];
|
|
9
|
+
for (const [key, entry] of this._references) {
|
|
10
|
+
if (key.startsWith(keyStart) && entry.model) {
|
|
11
|
+
models.push(await entry.model);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return models;
|
|
15
|
+
}
|
|
16
|
+
async get(resource, viewType) {
|
|
17
|
+
const key = this.key(resource, viewType);
|
|
18
|
+
const entry = this._references.get(key);
|
|
19
|
+
return entry?.model;
|
|
20
|
+
}
|
|
21
|
+
tryRetain(resource, viewType) {
|
|
22
|
+
const key = this.key(resource, viewType);
|
|
23
|
+
const entry = this._references.get(key);
|
|
24
|
+
if (!entry) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
entry.counter++;
|
|
28
|
+
return entry.model.then(model => {
|
|
29
|
+
return {
|
|
30
|
+
object: model,
|
|
31
|
+
dispose: createSingleCallFunction(() => {
|
|
32
|
+
if (--entry.counter <= 0) {
|
|
33
|
+
entry.model.then(x => x.dispose());
|
|
34
|
+
this._references.delete(key);
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
add(resource, viewType, model) {
|
|
41
|
+
const key = this.key(resource, viewType);
|
|
42
|
+
const existing = this._references.get(key);
|
|
43
|
+
if (existing) {
|
|
44
|
+
throw new Error('Model already exists');
|
|
45
|
+
}
|
|
46
|
+
this._references.set(key, { viewType, model, counter: 0 });
|
|
47
|
+
return this.tryRetain(resource, viewType);
|
|
48
|
+
}
|
|
49
|
+
disposeAllModelsForView(viewType) {
|
|
50
|
+
for (const [key, value] of this._references) {
|
|
51
|
+
if (value.viewType === viewType) {
|
|
52
|
+
value.model.then(x => x.dispose());
|
|
53
|
+
this._references.delete(key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
key(resource, viewType) {
|
|
58
|
+
return `${( resource.toString())}@@@${viewType}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export { CustomEditorModelManager };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { localizeWithPath } from '../../../../nls.js';
|
|
2
|
+
import { ExtensionsRegistry } from '../../../services/extensions/common/extensionsRegistry.js';
|
|
3
|
+
import { languagesExtPoint } from '../../../services/language/common/languageService.js';
|
|
4
|
+
const Fields = ( Object.freeze({
|
|
5
|
+
viewType: 'viewType',
|
|
6
|
+
displayName: 'displayName',
|
|
7
|
+
selector: 'selector',
|
|
8
|
+
priority: 'priority',
|
|
9
|
+
}));
|
|
10
|
+
const CustomEditorsContribution = {
|
|
11
|
+
description: ( localizeWithPath(
|
|
12
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
13
|
+
'contributes.customEditors',
|
|
14
|
+
'Contributed custom editors.'
|
|
15
|
+
)),
|
|
16
|
+
type: 'array',
|
|
17
|
+
defaultSnippets: [{
|
|
18
|
+
body: [{
|
|
19
|
+
[Fields.viewType]: '$1',
|
|
20
|
+
[Fields.displayName]: '$2',
|
|
21
|
+
[Fields.selector]: [{
|
|
22
|
+
filenamePattern: '$3'
|
|
23
|
+
}],
|
|
24
|
+
}]
|
|
25
|
+
}],
|
|
26
|
+
items: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
required: [
|
|
29
|
+
Fields.viewType,
|
|
30
|
+
Fields.displayName,
|
|
31
|
+
Fields.selector,
|
|
32
|
+
],
|
|
33
|
+
properties: {
|
|
34
|
+
[Fields.viewType]: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
markdownDescription: ( localizeWithPath(
|
|
37
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
38
|
+
'contributes.viewType',
|
|
39
|
+
'Identifier for the custom editor. This must be unique across all custom editors, so we recommend including your extension id as part of `viewType`. The `viewType` is used when registering custom editors with `vscode.registerCustomEditorProvider` and in the `onCustomEditor:${id}` [activation event](https://code.visualstudio.com/api/references/activation-events).'
|
|
40
|
+
)),
|
|
41
|
+
},
|
|
42
|
+
[Fields.displayName]: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: ( localizeWithPath(
|
|
45
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
46
|
+
'contributes.displayName',
|
|
47
|
+
'Human readable name of the custom editor. This is displayed to users when selecting which editor to use.'
|
|
48
|
+
)),
|
|
49
|
+
},
|
|
50
|
+
[Fields.selector]: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
description: ( localizeWithPath(
|
|
53
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
54
|
+
'contributes.selector',
|
|
55
|
+
'Set of globs that the custom editor is enabled for.'
|
|
56
|
+
)),
|
|
57
|
+
items: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
defaultSnippets: [{
|
|
60
|
+
body: {
|
|
61
|
+
filenamePattern: '$1',
|
|
62
|
+
}
|
|
63
|
+
}],
|
|
64
|
+
properties: {
|
|
65
|
+
filenamePattern: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: ( localizeWithPath(
|
|
68
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
69
|
+
'contributes.selector.filenamePattern',
|
|
70
|
+
'Glob that the custom editor is enabled for.'
|
|
71
|
+
)),
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[Fields.priority]: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
markdownDeprecationMessage: ( localizeWithPath(
|
|
79
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
80
|
+
'contributes.priority',
|
|
81
|
+
'Controls if the custom editor is enabled automatically when the user opens a file. This may be overridden by users using the `workbench.editorAssociations` setting.'
|
|
82
|
+
)),
|
|
83
|
+
enum: [
|
|
84
|
+
"default" ,
|
|
85
|
+
"option" ,
|
|
86
|
+
],
|
|
87
|
+
markdownEnumDescriptions: [
|
|
88
|
+
( localizeWithPath(
|
|
89
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
90
|
+
'contributes.priority.default',
|
|
91
|
+
'The editor is automatically used when the user opens a resource, provided that no other default custom editors are registered for that resource.'
|
|
92
|
+
)),
|
|
93
|
+
( localizeWithPath(
|
|
94
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
95
|
+
'contributes.priority.option',
|
|
96
|
+
'The editor is not automatically used when the user opens a resource, but a user can switch to the editor using the `Reopen With` command.'
|
|
97
|
+
)),
|
|
98
|
+
],
|
|
99
|
+
default: 'default'
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const customEditorsExtensionPoint = ( ExtensionsRegistry.registerExtensionPoint({
|
|
105
|
+
extensionPoint: 'customEditors',
|
|
106
|
+
deps: [languagesExtPoint],
|
|
107
|
+
jsonSchema: CustomEditorsContribution,
|
|
108
|
+
activationEventsGenerator: (contribs, result) => {
|
|
109
|
+
for (const contrib of contribs) {
|
|
110
|
+
const viewType = contrib[Fields.viewType];
|
|
111
|
+
if (viewType) {
|
|
112
|
+
result.push(`onCustomEditor:${viewType}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
}));
|
|
117
|
+
export { customEditorsExtensionPoint };
|