@codingame/monaco-vscode-view-common-service-override 4.5.0-improve-code-splitting.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/assets/fake.html +10 -0
- package/assets/index-no-csp.html +1230 -0
- package/assets/index.html +1231 -0
- package/assets/service-worker.js +457 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.js +5 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +11 -0
- package/package.json +32 -0
- package/tools/editorAssets.js +4 -0
- package/tools/url.js +10 -0
- package/viewCommon.d.ts +5 -0
- package/viewCommon.js +105 -0
- package/vscode/src/vs/base/browser/deviceAccess.js +61 -0
- package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +180 -0
- package/vscode/src/vs/base/browser/ui/grid/grid.js +494 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +6 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.js +1113 -0
- package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +12 -0
- package/vscode/src/vs/platform/webview/common/mimeTypes.js +24 -0
- package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +64 -0
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +907 -0
- package/vscode/src/vs/workbench/browser/actions/listCommands.js +764 -0
- package/vscode/src/vs/workbench/browser/actions/navigationActions.js +301 -0
- package/vscode/src/vs/workbench/browser/media/style.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +671 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +229 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/compositeBar.js +606 -0
- package/vscode/src/vs/workbench/browser/parts/compositePart.js +346 -0
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +246 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1403 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +188 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +523 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1030 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +391 -0
- package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +472 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +68 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +160 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +39 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +238 -0
- package/vscode/src/vs/workbench/browser/style.js +54 -0
- package/vscode/src/vs/workbench/browser/window.js +381 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +300 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +367 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +135 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +18 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +146 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +215 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +78 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +56 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +63 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +183 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +8 -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 +6 -0
- package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +147 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +635 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +230 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +75 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +81 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +350 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +100 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +148 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +106 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +403 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +199 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +41 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +128 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +619 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +161 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +266 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +173 -0
- package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +195 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +38 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +41 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +283 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +362 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +133 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +314 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +96 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +98 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +656 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +65 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +59 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +143 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +121 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +234 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewService.js +45 -0
- package/vscode/src/vs/workbench/services/activity/browser/activityService.js +145 -0
- package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +341 -0
- package/vscode/src/vs/workbench/services/driver/browser/driver.js +186 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorPaneService.js +13 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +676 -0
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +1516 -0
- package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +6 -0
- package/vscode/src/vs/workbench/services/progress/browser/progressService.js +527 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +102 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +133 -0
- package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
- package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +603 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import './media/customEditor.css.js';
|
|
3
|
+
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
4
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
5
|
+
import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
7
|
+
import { extname, isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
8
|
+
import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
|
|
9
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
10
|
+
import { UndoCommand, RedoCommand } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
11
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
12
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
13
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
14
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
15
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
16
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
17
|
+
import { EditorExtensions, DEFAULT_EDITOR_ASSOCIATION } from 'vscode/vscode/vs/workbench/common/editor';
|
|
18
|
+
import { DiffEditorInput } from 'vscode/vscode/vs/workbench/common/editor/diffEditorInput';
|
|
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 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
22
|
+
import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
23
|
+
import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService.service';
|
|
24
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
25
|
+
import { ContributedCustomEditors } from '../common/contributedCustomEditors.js';
|
|
26
|
+
import { CustomEditorInput } from 'vscode/vscode/vs/workbench/contrib/customEditor/browser/customEditorInput';
|
|
27
|
+
|
|
28
|
+
let CustomEditorService = class CustomEditorService extends Disposable {
|
|
29
|
+
constructor(contextKeyService, fileService, storageService, editorService, editorGroupService, instantiationService, uriIdentityService, editorResolverService) {
|
|
30
|
+
super();
|
|
31
|
+
this.editorService = editorService;
|
|
32
|
+
this.editorGroupService = editorGroupService;
|
|
33
|
+
this.instantiationService = instantiationService;
|
|
34
|
+
this.uriIdentityService = uriIdentityService;
|
|
35
|
+
this.editorResolverService = editorResolverService;
|
|
36
|
+
this._untitledCounter = 0;
|
|
37
|
+
this._editorResolverDisposables = this._register(( new DisposableStore()));
|
|
38
|
+
this._editorCapabilities = ( new Map());
|
|
39
|
+
this._models = ( new CustomEditorModelManager());
|
|
40
|
+
this._onDidChangeEditorTypes = this._register(( new Emitter()));
|
|
41
|
+
this.onDidChangeEditorTypes = this._onDidChangeEditorTypes.event;
|
|
42
|
+
this._fileEditorFactory = ( Registry.as(EditorExtensions.EditorFactory)).getFileEditorFactory();
|
|
43
|
+
this._activeCustomEditorId = CONTEXT_ACTIVE_CUSTOM_EDITOR_ID.bindTo(contextKeyService);
|
|
44
|
+
this._focusedCustomEditorIsEditable = CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE.bindTo(contextKeyService);
|
|
45
|
+
this._contributedEditors = this._register(( new ContributedCustomEditors(storageService)));
|
|
46
|
+
this.editorResolverService.bufferChangeEvents(this.registerContributionPoints.bind(this));
|
|
47
|
+
this._register(this._contributedEditors.onChange(() => {
|
|
48
|
+
this.editorResolverService.bufferChangeEvents(this.registerContributionPoints.bind(this));
|
|
49
|
+
this.updateContexts();
|
|
50
|
+
this._onDidChangeEditorTypes.fire();
|
|
51
|
+
}));
|
|
52
|
+
this._register(this.editorService.onDidActiveEditorChange(() => this.updateContexts()));
|
|
53
|
+
this._register(fileService.onDidRunOperation(e => {
|
|
54
|
+
if (e.isOperation(2 )) {
|
|
55
|
+
this.handleMovedFileInOpenedFileEditors(e.resource, this.uriIdentityService.asCanonicalUri(e.target.resource));
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
const PRIORITY = 105;
|
|
59
|
+
this._register(UndoCommand.addImplementation(PRIORITY, 'custom-editor', () => {
|
|
60
|
+
return this.withActiveCustomEditor(editor => editor.undo());
|
|
61
|
+
}));
|
|
62
|
+
this._register(RedoCommand.addImplementation(PRIORITY, 'custom-editor', () => {
|
|
63
|
+
return this.withActiveCustomEditor(editor => editor.redo());
|
|
64
|
+
}));
|
|
65
|
+
this.updateContexts();
|
|
66
|
+
}
|
|
67
|
+
getEditorTypes() {
|
|
68
|
+
return [...this._contributedEditors];
|
|
69
|
+
}
|
|
70
|
+
withActiveCustomEditor(f) {
|
|
71
|
+
const activeEditor = this.editorService.activeEditor;
|
|
72
|
+
if (activeEditor instanceof CustomEditorInput) {
|
|
73
|
+
const result = f(activeEditor);
|
|
74
|
+
if (result) {
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
registerContributionPoints() {
|
|
82
|
+
this._editorResolverDisposables.clear();
|
|
83
|
+
for (const contributedEditor of this._contributedEditors) {
|
|
84
|
+
for (const globPattern of contributedEditor.selector) {
|
|
85
|
+
if (!globPattern.filenamePattern) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
this._editorResolverDisposables.add(this.editorResolverService.registerEditor(globPattern.filenamePattern, {
|
|
89
|
+
id: contributedEditor.id,
|
|
90
|
+
label: contributedEditor.displayName,
|
|
91
|
+
detail: contributedEditor.providerDisplayName,
|
|
92
|
+
priority: contributedEditor.priority,
|
|
93
|
+
}, {
|
|
94
|
+
singlePerResource: () => !this.getCustomEditorCapabilities(contributedEditor.id)?.supportsMultipleEditorsPerDocument ?? true
|
|
95
|
+
}, {
|
|
96
|
+
createEditorInput: ({ resource }, group) => {
|
|
97
|
+
return { editor: CustomEditorInput.create(this.instantiationService, resource, contributedEditor.id, group.id) };
|
|
98
|
+
},
|
|
99
|
+
createUntitledEditorInput: ({ resource }, group) => {
|
|
100
|
+
return { editor: CustomEditorInput.create(this.instantiationService, resource ?? ( URI.from(
|
|
101
|
+
{ scheme: Schemas.untitled, authority: `Untitled-${this._untitledCounter++}` }
|
|
102
|
+
)), contributedEditor.id, group.id) };
|
|
103
|
+
},
|
|
104
|
+
createDiffEditorInput: (diffEditorInput, group) => {
|
|
105
|
+
return { editor: this.createDiffEditorInput(diffEditorInput, contributedEditor.id, group) };
|
|
106
|
+
},
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
createDiffEditorInput(editor, editorID, group) {
|
|
112
|
+
const modifiedOverride = CustomEditorInput.create(this.instantiationService, assertIsDefined(editor.modified.resource), editorID, group.id, { customClasses: 'modified' });
|
|
113
|
+
const originalOverride = CustomEditorInput.create(this.instantiationService, assertIsDefined(editor.original.resource), editorID, group.id, { customClasses: 'original' });
|
|
114
|
+
return this.instantiationService.createInstance(DiffEditorInput, editor.label, editor.description, originalOverride, modifiedOverride, true);
|
|
115
|
+
}
|
|
116
|
+
get models() { return this._models; }
|
|
117
|
+
getCustomEditor(viewType) {
|
|
118
|
+
return this._contributedEditors.get(viewType);
|
|
119
|
+
}
|
|
120
|
+
getContributedCustomEditors(resource) {
|
|
121
|
+
return ( new CustomEditorInfoCollection(this._contributedEditors.getContributedEditors(resource)));
|
|
122
|
+
}
|
|
123
|
+
getUserConfiguredCustomEditors(resource) {
|
|
124
|
+
const resourceAssocations = this.editorResolverService.getAssociationsForResource(resource);
|
|
125
|
+
return ( new CustomEditorInfoCollection(coalesce(( resourceAssocations
|
|
126
|
+
.map(association => this._contributedEditors.get(association.viewType))))));
|
|
127
|
+
}
|
|
128
|
+
getAllCustomEditors(resource) {
|
|
129
|
+
return ( new CustomEditorInfoCollection([
|
|
130
|
+
...this.getUserConfiguredCustomEditors(resource).allEditors,
|
|
131
|
+
...this.getContributedCustomEditors(resource).allEditors,
|
|
132
|
+
]));
|
|
133
|
+
}
|
|
134
|
+
registerCustomEditorCapabilities(viewType, options) {
|
|
135
|
+
if (( this._editorCapabilities.has(viewType))) {
|
|
136
|
+
throw new Error(`Capabilities for ${viewType} already set`);
|
|
137
|
+
}
|
|
138
|
+
this._editorCapabilities.set(viewType, options);
|
|
139
|
+
return toDisposable(() => {
|
|
140
|
+
this._editorCapabilities.delete(viewType);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getCustomEditorCapabilities(viewType) {
|
|
144
|
+
return this._editorCapabilities.get(viewType);
|
|
145
|
+
}
|
|
146
|
+
updateContexts() {
|
|
147
|
+
const activeEditorPane = this.editorService.activeEditorPane;
|
|
148
|
+
const resource = activeEditorPane?.input?.resource;
|
|
149
|
+
if (!resource) {
|
|
150
|
+
this._activeCustomEditorId.reset();
|
|
151
|
+
this._focusedCustomEditorIsEditable.reset();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this._activeCustomEditorId.set(activeEditorPane?.input instanceof CustomEditorInput ? activeEditorPane.input.viewType : '');
|
|
155
|
+
this._focusedCustomEditorIsEditable.set(activeEditorPane?.input instanceof CustomEditorInput);
|
|
156
|
+
}
|
|
157
|
+
async handleMovedFileInOpenedFileEditors(oldResource, newResource) {
|
|
158
|
+
if (extname(oldResource).toLowerCase() === extname(newResource).toLowerCase()) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const possibleEditors = this.getAllCustomEditors(newResource);
|
|
162
|
+
if (!( possibleEditors.allEditors.some(editor => editor.priority !== RegisteredEditorPriority.option))) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const editorsToReplace = ( new Map());
|
|
166
|
+
for (const group of this.editorGroupService.groups) {
|
|
167
|
+
for (const editor of group.editors) {
|
|
168
|
+
if (this._fileEditorFactory.isFileEditor(editor)
|
|
169
|
+
&& !(editor instanceof CustomEditorInput)
|
|
170
|
+
&& isEqual(editor.resource, newResource)) {
|
|
171
|
+
let entry = editorsToReplace.get(group.id);
|
|
172
|
+
if (!entry) {
|
|
173
|
+
entry = [];
|
|
174
|
+
editorsToReplace.set(group.id, entry);
|
|
175
|
+
}
|
|
176
|
+
entry.push(editor);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!editorsToReplace.size) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
for (const [group, entries] of editorsToReplace) {
|
|
184
|
+
this.editorService.replaceEditors(( entries.map(editor => {
|
|
185
|
+
let replacement;
|
|
186
|
+
if (possibleEditors.defaultEditor) {
|
|
187
|
+
const viewType = possibleEditors.defaultEditor.id;
|
|
188
|
+
replacement = CustomEditorInput.create(this.instantiationService, newResource, viewType, group);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
replacement = { resource: newResource, options: { override: DEFAULT_EDITOR_ASSOCIATION.id } };
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
editor,
|
|
195
|
+
replacement,
|
|
196
|
+
options: {
|
|
197
|
+
preserveFocus: true,
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
})), group);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
CustomEditorService = ( __decorate([
|
|
205
|
+
( __param(0, IContextKeyService)),
|
|
206
|
+
( __param(1, IFileService)),
|
|
207
|
+
( __param(2, IStorageService)),
|
|
208
|
+
( __param(3, IEditorService)),
|
|
209
|
+
( __param(4, IEditorGroupsService)),
|
|
210
|
+
( __param(5, IInstantiationService)),
|
|
211
|
+
( __param(6, IUriIdentityService)),
|
|
212
|
+
( __param(7, IEditorResolverService))
|
|
213
|
+
], CustomEditorService));
|
|
214
|
+
|
|
215
|
+
export { CustomEditorService };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
2
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
+
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
5
|
+
import { CustomEditorInfo } from './customEditor.js';
|
|
6
|
+
import { customEditorsExtensionPoint } from './extensionPoint.js';
|
|
7
|
+
import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
8
|
+
|
|
9
|
+
class ContributedCustomEditors extends Disposable {
|
|
10
|
+
static { this.CUSTOM_EDITORS_STORAGE_ID = 'customEditors'; }
|
|
11
|
+
static { this.CUSTOM_EDITORS_ENTRY_ID = 'editors'; }
|
|
12
|
+
constructor(storageService) {
|
|
13
|
+
super();
|
|
14
|
+
this._editors = ( new Map());
|
|
15
|
+
this._onChange = this._register(( new Emitter()));
|
|
16
|
+
this.onChange = this._onChange.event;
|
|
17
|
+
this._memento = ( new Memento(ContributedCustomEditors.CUSTOM_EDITORS_STORAGE_ID, storageService));
|
|
18
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
19
|
+
for (const info of (mementoObject[ContributedCustomEditors.CUSTOM_EDITORS_ENTRY_ID] || [])) {
|
|
20
|
+
this.add(( new CustomEditorInfo(info)));
|
|
21
|
+
}
|
|
22
|
+
customEditorsExtensionPoint.setHandler(extensions => {
|
|
23
|
+
this.update(extensions);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
update(extensions) {
|
|
27
|
+
this._editors.clear();
|
|
28
|
+
for (const extension of extensions) {
|
|
29
|
+
for (const webviewEditorContribution of extension.value) {
|
|
30
|
+
this.add(( new CustomEditorInfo({
|
|
31
|
+
id: webviewEditorContribution.viewType,
|
|
32
|
+
displayName: webviewEditorContribution.displayName,
|
|
33
|
+
providerDisplayName: extension.description.isBuiltin ? ( localizeWithPath(
|
|
34
|
+
'vs/workbench/contrib/customEditor/common/contributedCustomEditors',
|
|
35
|
+
'builtinProviderDisplayName',
|
|
36
|
+
"Built-in"
|
|
37
|
+
)) : extension.description.displayName || extension.description.identifier.value,
|
|
38
|
+
selector: webviewEditorContribution.selector || [],
|
|
39
|
+
priority: getPriorityFromContribution(webviewEditorContribution, extension.description),
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
44
|
+
mementoObject[ContributedCustomEditors.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( this._editors.values()));
|
|
45
|
+
this._memento.saveMemento();
|
|
46
|
+
this._onChange.fire();
|
|
47
|
+
}
|
|
48
|
+
[Symbol.iterator]() {
|
|
49
|
+
return ( this._editors.values());
|
|
50
|
+
}
|
|
51
|
+
get(viewType) {
|
|
52
|
+
return this._editors.get(viewType);
|
|
53
|
+
}
|
|
54
|
+
getContributedEditors(resource) {
|
|
55
|
+
return Array.from(( this._editors.values()))
|
|
56
|
+
.filter(customEditor => customEditor.matches(resource));
|
|
57
|
+
}
|
|
58
|
+
add(info) {
|
|
59
|
+
if (( this._editors.has(info.id))) {
|
|
60
|
+
console.error(`Custom editor with id '${info.id}' already registered`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._editors.set(info.id, info);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function getPriorityFromContribution(contribution, extension) {
|
|
67
|
+
switch (contribution.priority) {
|
|
68
|
+
case RegisteredEditorPriority.default:
|
|
69
|
+
case RegisteredEditorPriority.option:
|
|
70
|
+
return contribution.priority;
|
|
71
|
+
case RegisteredEditorPriority.builtin:
|
|
72
|
+
return extension.isBuiltin ? RegisteredEditorPriority.builtin : RegisteredEditorPriority.default;
|
|
73
|
+
default:
|
|
74
|
+
return RegisteredEditorPriority.default;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { ContributedCustomEditors };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { distinct } from 'vscode/vscode/vs/base/common/arrays';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { RawContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
4
|
+
import { globMatchesResource, RegisteredEditorPriority, priorityToRank } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
5
|
+
|
|
6
|
+
const CONTEXT_ACTIVE_CUSTOM_EDITOR_ID = ( new RawContextKey('activeCustomEditorId', '', {
|
|
7
|
+
type: 'string',
|
|
8
|
+
description: ( localizeWithPath(
|
|
9
|
+
'vs/workbench/contrib/customEditor/common/customEditor',
|
|
10
|
+
'context.customEditor',
|
|
11
|
+
"The viewType of the currently active custom editor."
|
|
12
|
+
)),
|
|
13
|
+
}));
|
|
14
|
+
const CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE = ( new RawContextKey('focusedCustomEditorIsEditable', false));
|
|
15
|
+
class CustomEditorInfo {
|
|
16
|
+
constructor(descriptor) {
|
|
17
|
+
this.id = descriptor.id;
|
|
18
|
+
this.displayName = descriptor.displayName;
|
|
19
|
+
this.providerDisplayName = descriptor.providerDisplayName;
|
|
20
|
+
this.priority = descriptor.priority;
|
|
21
|
+
this.selector = descriptor.selector;
|
|
22
|
+
}
|
|
23
|
+
matches(resource) {
|
|
24
|
+
return ( this.selector.some(
|
|
25
|
+
selector => selector.filenamePattern && globMatchesResource(selector.filenamePattern, resource)
|
|
26
|
+
));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class CustomEditorInfoCollection {
|
|
30
|
+
constructor(editors) {
|
|
31
|
+
this.allEditors = distinct(editors, editor => editor.id);
|
|
32
|
+
}
|
|
33
|
+
get length() { return this.allEditors.length; }
|
|
34
|
+
get defaultEditor() {
|
|
35
|
+
return this.allEditors.find(editor => {
|
|
36
|
+
switch (editor.priority) {
|
|
37
|
+
case RegisteredEditorPriority.default:
|
|
38
|
+
case RegisteredEditorPriority.builtin:
|
|
39
|
+
return this.allEditors.every(otherEditor => otherEditor === editor || isLowerPriority(otherEditor, editor));
|
|
40
|
+
default:
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
get bestAvailableEditor() {
|
|
46
|
+
const editors = Array.from(this.allEditors).sort((a, b) => {
|
|
47
|
+
return priorityToRank(a.priority) - priorityToRank(b.priority);
|
|
48
|
+
});
|
|
49
|
+
return editors[0];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function isLowerPriority(otherEditor, editor) {
|
|
53
|
+
return priorityToRank(otherEditor.priority) < priorityToRank(editor.priority);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { CONTEXT_ACTIVE_CUSTOM_EDITOR_ID, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorInfo, CustomEditorInfoCollection };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createSingleCallFunction } from 'vscode/vscode/vs/base/common/functional';
|
|
2
|
+
|
|
3
|
+
class CustomEditorModelManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._references = ( new Map());
|
|
6
|
+
}
|
|
7
|
+
async getAllModels(resource) {
|
|
8
|
+
const keyStart = `${( resource.toString())}@@@`;
|
|
9
|
+
const models = [];
|
|
10
|
+
for (const [key, entry] of this._references) {
|
|
11
|
+
if (key.startsWith(keyStart) && entry.model) {
|
|
12
|
+
models.push(await entry.model);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return models;
|
|
16
|
+
}
|
|
17
|
+
async get(resource, viewType) {
|
|
18
|
+
const key = this.key(resource, viewType);
|
|
19
|
+
const entry = this._references.get(key);
|
|
20
|
+
return entry?.model;
|
|
21
|
+
}
|
|
22
|
+
tryRetain(resource, viewType) {
|
|
23
|
+
const key = this.key(resource, viewType);
|
|
24
|
+
const entry = this._references.get(key);
|
|
25
|
+
if (!entry) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
entry.counter++;
|
|
29
|
+
return entry.model.then(model => {
|
|
30
|
+
return {
|
|
31
|
+
object: model,
|
|
32
|
+
dispose: createSingleCallFunction(() => {
|
|
33
|
+
if (--entry.counter <= 0) {
|
|
34
|
+
entry.model.then(x => x.dispose());
|
|
35
|
+
this._references.delete(key);
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
add(resource, viewType, model) {
|
|
42
|
+
const key = this.key(resource, viewType);
|
|
43
|
+
const existing = this._references.get(key);
|
|
44
|
+
if (existing) {
|
|
45
|
+
throw new Error('Model already exists');
|
|
46
|
+
}
|
|
47
|
+
this._references.set(key, { viewType, model, counter: 0 });
|
|
48
|
+
return this.tryRetain(resource, viewType);
|
|
49
|
+
}
|
|
50
|
+
disposeAllModelsForView(viewType) {
|
|
51
|
+
for (const [key, value] of this._references) {
|
|
52
|
+
if (value.viewType === viewType) {
|
|
53
|
+
value.model.then(x => x.dispose());
|
|
54
|
+
this._references.delete(key);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
key(resource, viewType) {
|
|
59
|
+
return `${( resource.toString())}@@@${viewType}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { CustomEditorModelManager };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
2
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
+
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
5
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
6
|
+
import { Extensions } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
|
|
7
|
+
import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
8
|
+
import { languagesExtPoint } from 'vscode/vscode/vs/workbench/services/language/common/languageService';
|
|
9
|
+
|
|
10
|
+
const Fields = ( Object.freeze({
|
|
11
|
+
viewType: 'viewType',
|
|
12
|
+
displayName: 'displayName',
|
|
13
|
+
selector: 'selector',
|
|
14
|
+
priority: 'priority',
|
|
15
|
+
}));
|
|
16
|
+
const CustomEditorsContribution = {
|
|
17
|
+
description: ( localizeWithPath(
|
|
18
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
19
|
+
'contributes.customEditors',
|
|
20
|
+
'Contributed custom editors.'
|
|
21
|
+
)),
|
|
22
|
+
type: 'array',
|
|
23
|
+
defaultSnippets: [{
|
|
24
|
+
body: [{
|
|
25
|
+
[Fields.viewType]: '$1',
|
|
26
|
+
[Fields.displayName]: '$2',
|
|
27
|
+
[Fields.selector]: [{
|
|
28
|
+
filenamePattern: '$3'
|
|
29
|
+
}],
|
|
30
|
+
}]
|
|
31
|
+
}],
|
|
32
|
+
items: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
required: [
|
|
35
|
+
Fields.viewType,
|
|
36
|
+
Fields.displayName,
|
|
37
|
+
Fields.selector,
|
|
38
|
+
],
|
|
39
|
+
properties: {
|
|
40
|
+
[Fields.viewType]: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
markdownDescription: ( localizeWithPath(
|
|
43
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
44
|
+
'contributes.viewType',
|
|
45
|
+
'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).'
|
|
46
|
+
)),
|
|
47
|
+
},
|
|
48
|
+
[Fields.displayName]: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: ( localizeWithPath(
|
|
51
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
52
|
+
'contributes.displayName',
|
|
53
|
+
'Human readable name of the custom editor. This is displayed to users when selecting which editor to use.'
|
|
54
|
+
)),
|
|
55
|
+
},
|
|
56
|
+
[Fields.selector]: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
description: ( localizeWithPath(
|
|
59
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
60
|
+
'contributes.selector',
|
|
61
|
+
'Set of globs that the custom editor is enabled for.'
|
|
62
|
+
)),
|
|
63
|
+
items: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
defaultSnippets: [{
|
|
66
|
+
body: {
|
|
67
|
+
filenamePattern: '$1',
|
|
68
|
+
}
|
|
69
|
+
}],
|
|
70
|
+
properties: {
|
|
71
|
+
filenamePattern: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: ( localizeWithPath(
|
|
74
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
75
|
+
'contributes.selector.filenamePattern',
|
|
76
|
+
'Glob that the custom editor is enabled for.'
|
|
77
|
+
)),
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
[Fields.priority]: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
markdownDeprecationMessage: ( localizeWithPath(
|
|
85
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
86
|
+
'contributes.priority',
|
|
87
|
+
'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.'
|
|
88
|
+
)),
|
|
89
|
+
enum: [
|
|
90
|
+
"default" ,
|
|
91
|
+
"option" ,
|
|
92
|
+
],
|
|
93
|
+
markdownEnumDescriptions: [
|
|
94
|
+
( localizeWithPath(
|
|
95
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
96
|
+
'contributes.priority.default',
|
|
97
|
+
'The editor is automatically used when the user opens a resource, provided that no other default custom editors are registered for that resource.'
|
|
98
|
+
)),
|
|
99
|
+
( localizeWithPath(
|
|
100
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
101
|
+
'contributes.priority.option',
|
|
102
|
+
'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.'
|
|
103
|
+
)),
|
|
104
|
+
],
|
|
105
|
+
default: 'default'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const customEditorsExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
111
|
+
extensionPoint: 'customEditors',
|
|
112
|
+
deps: [languagesExtPoint],
|
|
113
|
+
jsonSchema: CustomEditorsContribution,
|
|
114
|
+
activationEventsGenerator: (contribs, result) => {
|
|
115
|
+
for (const contrib of contribs) {
|
|
116
|
+
const viewType = contrib[Fields.viewType];
|
|
117
|
+
if (viewType) {
|
|
118
|
+
result.push(`onCustomEditor:${viewType}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
class CustomEditorsDataRenderer extends Disposable {
|
|
124
|
+
constructor() {
|
|
125
|
+
super(...arguments);
|
|
126
|
+
this.type = 'table';
|
|
127
|
+
}
|
|
128
|
+
shouldRender(manifest) {
|
|
129
|
+
return !!manifest.contributes?.customEditors;
|
|
130
|
+
}
|
|
131
|
+
render(manifest) {
|
|
132
|
+
const customEditors = manifest.contributes?.customEditors || [];
|
|
133
|
+
if (!customEditors.length) {
|
|
134
|
+
return { data: { headers: [], rows: [] }, dispose: () => { } };
|
|
135
|
+
}
|
|
136
|
+
const headers = [
|
|
137
|
+
( localizeWithPath(
|
|
138
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
139
|
+
'customEditors view type',
|
|
140
|
+
"View Type"
|
|
141
|
+
)),
|
|
142
|
+
( localizeWithPath(
|
|
143
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
144
|
+
'customEditors priority',
|
|
145
|
+
"Priority"
|
|
146
|
+
)),
|
|
147
|
+
( localizeWithPath(
|
|
148
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
149
|
+
'customEditors filenamePattern',
|
|
150
|
+
"Filename Pattern"
|
|
151
|
+
)),
|
|
152
|
+
];
|
|
153
|
+
const rows = ( customEditors
|
|
154
|
+
.map(customEditor => {
|
|
155
|
+
return [
|
|
156
|
+
customEditor.viewType,
|
|
157
|
+
customEditor.priority ?? '',
|
|
158
|
+
coalesce(( customEditor.selector.map(x => x.filenamePattern))).join(', ')
|
|
159
|
+
];
|
|
160
|
+
}));
|
|
161
|
+
return {
|
|
162
|
+
data: {
|
|
163
|
+
headers,
|
|
164
|
+
rows
|
|
165
|
+
},
|
|
166
|
+
dispose: () => { }
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
( Registry.as(Extensions.ExtensionFeaturesRegistry)).registerExtensionFeature({
|
|
171
|
+
id: 'customEditors',
|
|
172
|
+
label: ( localizeWithPath(
|
|
173
|
+
'vs/workbench/contrib/customEditor/common/extensionPoint',
|
|
174
|
+
'customEditors',
|
|
175
|
+
"Custom Editors"
|
|
176
|
+
)),
|
|
177
|
+
access: {
|
|
178
|
+
canToggle: false
|
|
179
|
+
},
|
|
180
|
+
renderer: ( new SyncDescriptor(CustomEditorsDataRenderer)),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export { customEditorsExtensionPoint };
|
package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
2
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
3
|
+
import { externalUriOpenersConfigurationNode } from 'vscode/vscode/vs/workbench/contrib/externalUriOpener/common/configuration';
|
|
4
|
+
import 'vscode/vscode/vs/workbench/contrib/externalUriOpener/common/externalUriOpenerService';
|
|
5
|
+
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
+
|
|
7
|
+
( Registry.as(Extensions.Configuration))
|
|
8
|
+
.registerConfiguration(externalUriOpenersConfigurationNode);
|