@codingame/monaco-vscode-editor-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/esm/vs/editor/editor.api.js +4 -729
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigurationChangedEvent, ApplyUpdateResult, EditorOptions } from 'vscode/vscode/vs/editor/common/config/editorOptions';
|
|
2
2
|
import { createMonacoBaseAPI } from 'vscode/vscode/vs/editor/common/services/editorBaseApi';
|
|
3
3
|
import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
4
|
-
import { Disposable, DisposableStore
|
|
4
|
+
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
5
|
import { startsWithUTF8BOM, splitLines } from 'vscode/vscode/vs/base/common/strings';
|
|
6
6
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
7
7
|
import { FontMeasurements } from 'vscode/vscode/vs/editor/browser/config/fontMeasurements';
|
|
@@ -27,47 +27,19 @@ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/c
|
|
|
27
27
|
import { StandaloneEditor, StandaloneDiffEditor2, createTextModel } from 'vscode/vscode/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
28
28
|
import { StandaloneServices, StandaloneKeybindingService } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
29
29
|
import { IStandaloneThemeService } from 'vscode/vscode/vs/editor/standalone/common/standaloneTheme';
|
|
30
|
-
import {
|
|
30
|
+
import { MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
31
31
|
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
32
|
-
import {
|
|
32
|
+
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
33
33
|
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
34
34
|
import { IMarkerService } from 'vscode/vscode/vs/platform/markers/common/markers';
|
|
35
35
|
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
36
|
-
import {
|
|
37
|
-
import { h, scheduleAtNextAnimationFrame, getWindow } from 'vscode/vscode/vs/base/browser/dom';
|
|
38
|
-
import { SmoothScrollableElement } from 'vscode/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
|
|
39
|
-
import { findFirstMaxBy } from 'vscode/vscode/vs/base/common/arraysFind';
|
|
40
|
-
import { observableValue, globalTransaction, transaction, disposableObservableValue } from 'vscode/vscode/vs/base/common/observableInternal/base';
|
|
41
|
-
import { Scrollable } from 'vscode/vscode/vs/base/common/scrollable';
|
|
42
|
-
import { OffsetRange } from 'vscode/vscode/vs/editor/common/core/offsetRange';
|
|
43
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
44
|
-
import { Button } from 'vscode/vscode/vs/base/browser/ui/button/button';
|
|
45
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
46
|
-
import { DiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/diffEditorWidget';
|
|
47
|
-
import { MenuWorkbenchToolBar } from 'vscode/vscode/vs/platform/actions/browser/toolbar';
|
|
48
|
-
import { ActionRunner } from 'vscode/vscode/vs/base/common/actions';
|
|
49
|
-
import { derived, derivedWithStore } from 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
50
|
-
import { autorun, autorunWithStore } from 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
51
|
-
import { observableFromEvent, derivedObservableWithCache, mapObservableArrayCached, recomputeInitiallyAndOnChange } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
52
|
-
import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
|
|
53
|
-
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
54
|
-
import { Selection as Selection$1 } from 'vscode/vscode/vs/editor/common/core/selection';
|
|
55
|
-
import { DiffEditorOptions } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/diffEditorOptions';
|
|
56
|
-
import { DiffEditorViewModel } from 'vscode/vscode/vs/editor/browser/widget/diffEditor/diffEditorViewModel';
|
|
57
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
58
|
-
import { registerColor } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
|
|
59
|
-
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
36
|
+
import { MultiDiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget';
|
|
60
37
|
import { Color } from 'vscode/vscode/vs/base/common/color';
|
|
61
38
|
import { Range as Range$1 } from 'vscode/vscode/vs/editor/common/core/range';
|
|
62
39
|
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
63
40
|
import { FormattingConflicts } from 'vscode/vscode/vs/editor/contrib/format/browser/format';
|
|
64
41
|
import { createConfiguredEditor, createConfiguredDiffEditor, createModelReference, writeFile } from 'vscode/monaco';
|
|
65
42
|
|
|
66
|
-
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
67
|
-
|
|
68
|
-
var css$1 = ".monaco-editor{--monaco-monospace-font:\"SF Mono\",Monaco,Menlo,Consolas,\"Ubuntu Mono\",\"Liberation Mono\",\"DejaVu Sans Mono\",\"Courier New\",monospace;font-family:-apple-system,BlinkMacSystemFont,Segoe WPC,Segoe UI,HelveticaNeue-Light,system-ui,Ubuntu,Droid Sans,sans-serif}.monaco-editor.hc-black .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label,.monaco-editor.hc-light .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label,.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label,.monaco-menu .monaco-action-bar.vertical .action-item .action-menu-item:focus .action-label{stroke-width:1.2px}.monaco-hover p{margin:0}.monaco-aria-container{clip:rect(1px,1px,1px,1px);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute!important;top:0;width:1px}.monaco-diff-editor .synthetic-focus,.monaco-diff-editor [tabindex=\"-1\"]:focus,.monaco-diff-editor [tabindex=\"0\"]:focus,.monaco-diff-editor button:focus,.monaco-diff-editor input[type=button]:focus,.monaco-diff-editor input[type=checkbox]:focus,.monaco-diff-editor input[type=search]:focus,.monaco-diff-editor input[type=text]:focus,.monaco-diff-editor select:focus,.monaco-diff-editor textarea:focus,.monaco-editor{opacity:1;outline-color:var(--vscode-focusBorder);outline-offset:-1px;outline-style:solid;outline-width:1px}";
|
|
69
|
-
n(css$1,{});
|
|
70
|
-
|
|
71
43
|
function __decorate(decorators, target, key, desc) {
|
|
72
44
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
73
45
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1030,703 +1002,6 @@ function _actualColorize(lines, tabSize, tokenizationSupport, languageIdCodec) {
|
|
|
1030
1002
|
return html.join('');
|
|
1031
1003
|
}
|
|
1032
1004
|
|
|
1033
|
-
var css = ".monaco-component.multiDiffEditor{background:var(--vscode-multiDiffEditor-background);overflow-y:hidden}.monaco-component .multiDiffEntry{border-bottom:1px solid var(--vscode-multiDiffEditor-border);display:flex;flex:1;flex-direction:column;overflow:hidden}.monaco-component .multiDiffEntry .collapse-button{cursor:pointer;margin:0 5px}.monaco-component .multiDiffEntry .collapse-button a{display:block}.monaco-component .multiDiffEntry .header{align-items:center;background:var(--vscode-editor-background);border-bottom:1px solid var(--vscode-sideBarSectionHeader-border);border-top:1px solid var(--vscode-multiDiffEditor-border);color:var(--vscode-foreground);display:flex;padding:8px 5px;z-index:1000}.monaco-component .multiDiffEntry .header.shadow{box-shadow:var(--vscode-scrollbar-shadow) 0 6px 6px -6px}.monaco-component .multiDiffEntry .header .file-path{display:flex;flex:1;min-width:0}.monaco-component .multiDiffEntry .header .file-path .title{font-size:14px;line-height:22px}.monaco-component .multiDiffEntry .header .file-path .status{font-weight:600;line-height:22px;margin:0 10px;opacity:.75}.monaco-component .multiDiffEntry .header .file-path .title.original{flex:1;min-width:0;text-overflow:ellipsis}.monaco-component .multiDiffEntry .header .actions{padding:0 8px}.monaco-component .multiDiffEntry .editorParent{display:flex;flex:1;flex-direction:column}.monaco-component .multiDiffEntry .editorContainer{flex:1}";
|
|
1034
|
-
n(css,{});
|
|
1035
|
-
|
|
1036
|
-
class ActionRunnerWithContext extends ActionRunner {
|
|
1037
|
-
constructor(_getContext) {
|
|
1038
|
-
super();
|
|
1039
|
-
this._getContext = _getContext;
|
|
1040
|
-
}
|
|
1041
|
-
runAction(action, _context) {
|
|
1042
|
-
return super.runAction(action, this._getContext());
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
class TemplateData {
|
|
1047
|
-
constructor(viewModel) {
|
|
1048
|
-
this.viewModel = viewModel;
|
|
1049
|
-
}
|
|
1050
|
-
getId() {
|
|
1051
|
-
return this.viewModel;
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
let DiffEditorItemTemplate = class DiffEditorItemTemplate extends Disposable {
|
|
1055
|
-
constructor(_container, _overflowWidgetsDomNode, _workbenchUIElementFactory, _instantiationService) {
|
|
1056
|
-
super();
|
|
1057
|
-
this._container = _container;
|
|
1058
|
-
this._overflowWidgetsDomNode = _overflowWidgetsDomNode;
|
|
1059
|
-
this._workbenchUIElementFactory = _workbenchUIElementFactory;
|
|
1060
|
-
this._instantiationService = _instantiationService;
|
|
1061
|
-
this._viewModel = observableValue(this, undefined);
|
|
1062
|
-
this._collapsed = derived(this, reader => this._viewModel.read(reader)?.collapsed.read(reader));
|
|
1063
|
-
this._editorContentHeight = observableValue(this, 500);
|
|
1064
|
-
this.contentHeight = derived(this, reader => {
|
|
1065
|
-
const h = this._collapsed.read(reader) ? 0 : this._editorContentHeight.read(reader);
|
|
1066
|
-
return h + this._outerEditorHeight;
|
|
1067
|
-
});
|
|
1068
|
-
this._modifiedContentWidth = observableValue(this, 0);
|
|
1069
|
-
this._modifiedWidth = observableValue(this, 0);
|
|
1070
|
-
this._originalContentWidth = observableValue(this, 0);
|
|
1071
|
-
this._originalWidth = observableValue(this, 0);
|
|
1072
|
-
this.maxScroll = derived(this, reader => {
|
|
1073
|
-
const scroll1 = this._modifiedContentWidth.read(reader) - this._modifiedWidth.read(reader);
|
|
1074
|
-
const scroll2 = this._originalContentWidth.read(reader) - this._originalWidth.read(reader);
|
|
1075
|
-
if (scroll1 > scroll2) {
|
|
1076
|
-
return { maxScroll: scroll1, width: this._modifiedWidth.read(reader) };
|
|
1077
|
-
}
|
|
1078
|
-
else {
|
|
1079
|
-
return { maxScroll: scroll2, width: this._originalWidth.read(reader) };
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
1082
|
-
this._elements = h('div.multiDiffEntry', [
|
|
1083
|
-
h('div.header@header', [
|
|
1084
|
-
h('div.collapse-button@collapseButton'),
|
|
1085
|
-
h('div.file-path', [
|
|
1086
|
-
h('div.title.modified.show-file-icons@primaryPath', []),
|
|
1087
|
-
h('div.status.deleted@status', ['R']),
|
|
1088
|
-
h('div.title.original.show-file-icons@secondaryPath', []),
|
|
1089
|
-
]),
|
|
1090
|
-
h('div.actions@actions'),
|
|
1091
|
-
]),
|
|
1092
|
-
h('div.editorParent', [
|
|
1093
|
-
h('div.editorContainer@editor'),
|
|
1094
|
-
])
|
|
1095
|
-
]);
|
|
1096
|
-
this.editor = this._register(this._instantiationService.createInstance(DiffEditorWidget, this._elements.editor, {
|
|
1097
|
-
overflowWidgetsDomNode: this._overflowWidgetsDomNode,
|
|
1098
|
-
}, {}));
|
|
1099
|
-
this.isModifedFocused = isFocused(this.editor.getModifiedEditor());
|
|
1100
|
-
this.isOriginalFocused = isFocused(this.editor.getOriginalEditor());
|
|
1101
|
-
this.isFocused = derived(this, reader => this.isModifedFocused.read(reader) || this.isOriginalFocused.read(reader));
|
|
1102
|
-
this._resourceLabel = this._workbenchUIElementFactory.createResourceLabel
|
|
1103
|
-
? this._register(this._workbenchUIElementFactory.createResourceLabel(this._elements.primaryPath))
|
|
1104
|
-
: undefined;
|
|
1105
|
-
this._resourceLabel2 = this._workbenchUIElementFactory.createResourceLabel
|
|
1106
|
-
? this._register(this._workbenchUIElementFactory.createResourceLabel(this._elements.secondaryPath))
|
|
1107
|
-
: undefined;
|
|
1108
|
-
this._dataStore = ( new DisposableStore());
|
|
1109
|
-
this._headerHeight = 38;
|
|
1110
|
-
const btn = ( new Button(this._elements.collapseButton, {}));
|
|
1111
|
-
this._register(autorun(reader => {
|
|
1112
|
-
btn.element.className = '';
|
|
1113
|
-
btn.icon = this._collapsed.read(reader) ? Codicon.chevronRight : Codicon.chevronDown;
|
|
1114
|
-
}));
|
|
1115
|
-
this._register(btn.onDidClick(() => {
|
|
1116
|
-
this._viewModel.get()?.collapsed.set(!this._collapsed.get(), undefined);
|
|
1117
|
-
}));
|
|
1118
|
-
this._register(autorun(reader => {
|
|
1119
|
-
this._elements.editor.style.display = this._collapsed.read(reader) ? 'none' : 'block';
|
|
1120
|
-
}));
|
|
1121
|
-
this.editor.getModifiedEditor().onDidLayoutChange(e => {
|
|
1122
|
-
const width = this.editor.getModifiedEditor().getLayoutInfo().contentWidth;
|
|
1123
|
-
this._modifiedWidth.set(width, undefined);
|
|
1124
|
-
});
|
|
1125
|
-
this.editor.getOriginalEditor().onDidLayoutChange(e => {
|
|
1126
|
-
const width = this.editor.getOriginalEditor().getLayoutInfo().contentWidth;
|
|
1127
|
-
this._originalWidth.set(width, undefined);
|
|
1128
|
-
});
|
|
1129
|
-
this._register(this.editor.onDidContentSizeChange(e => {
|
|
1130
|
-
globalTransaction(tx => {
|
|
1131
|
-
this._editorContentHeight.set(e.contentHeight, tx);
|
|
1132
|
-
this._modifiedContentWidth.set(this.editor.getModifiedEditor().getContentWidth(), tx);
|
|
1133
|
-
this._originalContentWidth.set(this.editor.getOriginalEditor().getContentWidth(), tx);
|
|
1134
|
-
});
|
|
1135
|
-
}));
|
|
1136
|
-
this._register(autorun(reader => {
|
|
1137
|
-
const isFocused = this.isFocused.read(reader);
|
|
1138
|
-
this._elements.root.classList.toggle('focused', isFocused);
|
|
1139
|
-
}));
|
|
1140
|
-
this._container.appendChild(this._elements.root);
|
|
1141
|
-
this._outerEditorHeight = 38;
|
|
1142
|
-
this._register(this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.actions, MenuId.MultiDiffEditorFileToolbar, {
|
|
1143
|
-
actionRunner: this._register(( new ActionRunnerWithContext(() => (this._viewModel.get()?.modifiedUri)))),
|
|
1144
|
-
menuOptions: {
|
|
1145
|
-
shouldForwardArgs: true,
|
|
1146
|
-
},
|
|
1147
|
-
toolbarOptions: { primaryGroup: g => g.startsWith('navigation') },
|
|
1148
|
-
}));
|
|
1149
|
-
}
|
|
1150
|
-
setScrollLeft(left) {
|
|
1151
|
-
if (this._modifiedContentWidth.get() - this._modifiedWidth.get() > this._originalContentWidth.get() - this._originalWidth.get()) {
|
|
1152
|
-
this.editor.getModifiedEditor().setScrollLeft(left);
|
|
1153
|
-
}
|
|
1154
|
-
else {
|
|
1155
|
-
this.editor.getOriginalEditor().setScrollLeft(left);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
setData(data) {
|
|
1159
|
-
function updateOptions(options) {
|
|
1160
|
-
return {
|
|
1161
|
-
...options,
|
|
1162
|
-
scrollBeyondLastLine: false,
|
|
1163
|
-
hideUnchangedRegions: {
|
|
1164
|
-
enabled: true,
|
|
1165
|
-
},
|
|
1166
|
-
scrollbar: {
|
|
1167
|
-
vertical: 'hidden',
|
|
1168
|
-
horizontal: 'hidden',
|
|
1169
|
-
handleMouseWheel: false,
|
|
1170
|
-
useShadows: false,
|
|
1171
|
-
},
|
|
1172
|
-
renderOverviewRuler: false,
|
|
1173
|
-
fixedOverflowWidgets: true,
|
|
1174
|
-
overviewRulerBorder: false,
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
const value = data.viewModel.entry.value;
|
|
1178
|
-
if (value.onOptionsDidChange) {
|
|
1179
|
-
this._dataStore.add(value.onOptionsDidChange(() => {
|
|
1180
|
-
this.editor.updateOptions(updateOptions(value.options ?? {}));
|
|
1181
|
-
}));
|
|
1182
|
-
}
|
|
1183
|
-
globalTransaction(tx => {
|
|
1184
|
-
this._resourceLabel?.setUri(data.viewModel.modifiedUri ?? data.viewModel.originalUri, { strikethrough: data.viewModel.modifiedUri === undefined });
|
|
1185
|
-
let isRenamed = false;
|
|
1186
|
-
let isDeleted = false;
|
|
1187
|
-
let isAdded = false;
|
|
1188
|
-
let flag = '';
|
|
1189
|
-
if (data.viewModel.modifiedUri && data.viewModel.originalUri && data.viewModel.modifiedUri.path !== data.viewModel.originalUri.path) {
|
|
1190
|
-
flag = 'R';
|
|
1191
|
-
isRenamed = true;
|
|
1192
|
-
}
|
|
1193
|
-
else if (!data.viewModel.modifiedUri) {
|
|
1194
|
-
flag = 'D';
|
|
1195
|
-
isDeleted = true;
|
|
1196
|
-
}
|
|
1197
|
-
else if (!data.viewModel.originalUri) {
|
|
1198
|
-
flag = 'A';
|
|
1199
|
-
isAdded = true;
|
|
1200
|
-
}
|
|
1201
|
-
this._elements.status.classList.toggle('renamed', isRenamed);
|
|
1202
|
-
this._elements.status.classList.toggle('deleted', isDeleted);
|
|
1203
|
-
this._elements.status.classList.toggle('added', isAdded);
|
|
1204
|
-
this._elements.status.innerText = flag;
|
|
1205
|
-
this._resourceLabel2?.setUri(isRenamed ? data.viewModel.originalUri : undefined, { strikethrough: true });
|
|
1206
|
-
this._dataStore.clear();
|
|
1207
|
-
this._viewModel.set(data.viewModel, tx);
|
|
1208
|
-
this.editor.setModel(data.viewModel.diffEditorViewModel, tx);
|
|
1209
|
-
this.editor.updateOptions(updateOptions(value.options ?? {}));
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
render(verticalRange, width, editorScroll, viewPort) {
|
|
1213
|
-
this._elements.root.style.visibility = 'visible';
|
|
1214
|
-
this._elements.root.style.top = `${verticalRange.start}px`;
|
|
1215
|
-
this._elements.root.style.height = `${verticalRange.length}px`;
|
|
1216
|
-
this._elements.root.style.width = `${width}px`;
|
|
1217
|
-
this._elements.root.style.position = 'absolute';
|
|
1218
|
-
const delta = Math.max(0, Math.min(verticalRange.length - this._headerHeight, viewPort.start - verticalRange.start));
|
|
1219
|
-
this._elements.header.style.transform = `translateY(${delta}px)`;
|
|
1220
|
-
globalTransaction(tx => {
|
|
1221
|
-
this.editor.layout({
|
|
1222
|
-
width: width,
|
|
1223
|
-
height: verticalRange.length - this._outerEditorHeight,
|
|
1224
|
-
});
|
|
1225
|
-
});
|
|
1226
|
-
this.editor.getOriginalEditor().setScrollTop(editorScroll);
|
|
1227
|
-
this._elements.header.classList.toggle('shadow', delta > 0 || editorScroll > 0);
|
|
1228
|
-
}
|
|
1229
|
-
hide() {
|
|
1230
|
-
this._elements.root.style.top = `-100000px`;
|
|
1231
|
-
this._elements.root.style.visibility = 'hidden';
|
|
1232
|
-
}
|
|
1233
|
-
};
|
|
1234
|
-
DiffEditorItemTemplate = ( __decorate([
|
|
1235
|
-
( __param(3, IInstantiationService))
|
|
1236
|
-
], DiffEditorItemTemplate));
|
|
1237
|
-
function isFocused(editor) {
|
|
1238
|
-
return observableFromEvent(h => {
|
|
1239
|
-
const store = ( new DisposableStore());
|
|
1240
|
-
store.add(editor.onDidFocusEditorWidget(() => h(true)));
|
|
1241
|
-
store.add(editor.onDidBlurEditorWidget(() => h(false)));
|
|
1242
|
-
return store;
|
|
1243
|
-
}, () => editor.hasWidgetFocus());
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
class ObjectPool {
|
|
1247
|
-
constructor(_create) {
|
|
1248
|
-
this._create = _create;
|
|
1249
|
-
this._unused = ( new Set());
|
|
1250
|
-
this._used = ( new Set());
|
|
1251
|
-
this._itemData = ( new Map());
|
|
1252
|
-
}
|
|
1253
|
-
getUnusedObj(data) {
|
|
1254
|
-
let obj;
|
|
1255
|
-
if (this._unused.size === 0) {
|
|
1256
|
-
obj = this._create(data);
|
|
1257
|
-
this._itemData.set(obj, data);
|
|
1258
|
-
}
|
|
1259
|
-
else {
|
|
1260
|
-
const values = [...( this._unused.values())];
|
|
1261
|
-
obj = values.find(obj => this._itemData.get(obj).getId() === data.getId()) ?? values[0];
|
|
1262
|
-
this._unused.delete(obj);
|
|
1263
|
-
this._itemData.set(obj, data);
|
|
1264
|
-
obj.setData(data);
|
|
1265
|
-
}
|
|
1266
|
-
this._used.add(obj);
|
|
1267
|
-
return {
|
|
1268
|
-
object: obj,
|
|
1269
|
-
dispose: () => {
|
|
1270
|
-
this._used.delete(obj);
|
|
1271
|
-
if (this._unused.size > 5) {
|
|
1272
|
-
obj.dispose();
|
|
1273
|
-
}
|
|
1274
|
-
else {
|
|
1275
|
-
this._unused.add(obj);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
}
|
|
1280
|
-
dispose() {
|
|
1281
|
-
for (const obj of this._used) {
|
|
1282
|
-
obj.dispose();
|
|
1283
|
-
}
|
|
1284
|
-
for (const obj of this._unused) {
|
|
1285
|
-
obj.dispose();
|
|
1286
|
-
}
|
|
1287
|
-
this._used.clear();
|
|
1288
|
-
this._unused.clear();
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
let MultiDiffEditorWidgetImpl = class MultiDiffEditorWidgetImpl extends Disposable {
|
|
1293
|
-
constructor(_element, _dimension, _viewModel, _workbenchUIElementFactory, _parentContextKeyService, _parentInstantiationService) {
|
|
1294
|
-
super();
|
|
1295
|
-
this._element = _element;
|
|
1296
|
-
this._dimension = _dimension;
|
|
1297
|
-
this._viewModel = _viewModel;
|
|
1298
|
-
this._workbenchUIElementFactory = _workbenchUIElementFactory;
|
|
1299
|
-
this._parentContextKeyService = _parentContextKeyService;
|
|
1300
|
-
this._parentInstantiationService = _parentInstantiationService;
|
|
1301
|
-
this._elements = h('div.monaco-component.multiDiffEditor', [
|
|
1302
|
-
h('div@content', {
|
|
1303
|
-
style: {
|
|
1304
|
-
overflow: 'hidden',
|
|
1305
|
-
}
|
|
1306
|
-
}),
|
|
1307
|
-
h('div.monaco-editor@overflowWidgetsDomNode', {}),
|
|
1308
|
-
]);
|
|
1309
|
-
this._sizeObserver = this._register(( new ObservableElementSizeObserver(this._element, undefined)));
|
|
1310
|
-
this._objectPool = this._register(( new ObjectPool((data) => {
|
|
1311
|
-
const template = this._instantiationService.createInstance(DiffEditorItemTemplate, this._elements.content, this._elements.overflowWidgetsDomNode, this._workbenchUIElementFactory);
|
|
1312
|
-
template.setData(data);
|
|
1313
|
-
return template;
|
|
1314
|
-
})));
|
|
1315
|
-
this._scrollable = this._register(( new Scrollable({
|
|
1316
|
-
forceIntegerValues: false,
|
|
1317
|
-
scheduleAtNextAnimationFrame: (cb) => scheduleAtNextAnimationFrame(getWindow(this._element), cb),
|
|
1318
|
-
smoothScrollDuration: 100,
|
|
1319
|
-
})));
|
|
1320
|
-
this._scrollableElement = this._register(( new SmoothScrollableElement(this._elements.root, {
|
|
1321
|
-
vertical: 1 ,
|
|
1322
|
-
horizontal: 1 ,
|
|
1323
|
-
useShadows: false,
|
|
1324
|
-
}, this._scrollable)));
|
|
1325
|
-
this.scrollTop = observableFromEvent(this._scrollableElement.onScroll, () => this._scrollableElement.getScrollPosition().scrollTop);
|
|
1326
|
-
this.scrollLeft = observableFromEvent(this._scrollableElement.onScroll, () => this._scrollableElement.getScrollPosition().scrollLeft);
|
|
1327
|
-
this._viewItems = derivedWithStore(this, (reader, store) => {
|
|
1328
|
-
const vm = this._viewModel.read(reader);
|
|
1329
|
-
if (!vm) {
|
|
1330
|
-
return [];
|
|
1331
|
-
}
|
|
1332
|
-
const items = vm.items.read(reader);
|
|
1333
|
-
return ( items.map(d => {
|
|
1334
|
-
const item = store.add(( new VirtualizedViewItem(d, this._objectPool, this.scrollLeft)));
|
|
1335
|
-
const data = this._lastDocStates?.[item.getKey()];
|
|
1336
|
-
if (data) {
|
|
1337
|
-
transaction(tx => {
|
|
1338
|
-
item.setViewState(data, tx);
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
return item;
|
|
1342
|
-
}));
|
|
1343
|
-
});
|
|
1344
|
-
this._spaceBetweenPx = 10;
|
|
1345
|
-
this._totalHeight = ( this._viewItems.map(
|
|
1346
|
-
this,
|
|
1347
|
-
(items, reader) => items.reduce((r, i) => r + i.contentHeight.read(reader) + this._spaceBetweenPx, 0)
|
|
1348
|
-
));
|
|
1349
|
-
this.activeDiffItem = derived(this, reader => this._viewItems.read(reader).find(i => i.template.read(reader)?.isFocused.read(reader)));
|
|
1350
|
-
this.lastActiveDiffItem = derivedObservableWithCache((reader, lastValue) => this.activeDiffItem.read(reader) ?? lastValue);
|
|
1351
|
-
this.activeControl = derived(this, reader => this.lastActiveDiffItem.read(reader)?.template.read(reader)?.editor);
|
|
1352
|
-
this._contextKeyService = this._register(this._parentContextKeyService.createScoped(this._element));
|
|
1353
|
-
this._instantiationService = this._parentInstantiationService.createChild(( new ServiceCollection([IContextKeyService, this._contextKeyService])));
|
|
1354
|
-
this._lastDocStates = {};
|
|
1355
|
-
this._contextKeyService.createKey(EditorContextKeys.inMultiDiffEditor.key, true);
|
|
1356
|
-
this._register(autorunWithStore((reader, store) => {
|
|
1357
|
-
const viewModel = this._viewModel.read(reader);
|
|
1358
|
-
if (viewModel && viewModel.contextKeys) {
|
|
1359
|
-
for (const [key, value] of Object.entries(viewModel.contextKeys)) {
|
|
1360
|
-
const contextKey = this._contextKeyService.createKey(key, undefined);
|
|
1361
|
-
contextKey.set(value);
|
|
1362
|
-
store.add(toDisposable(() => contextKey.reset()));
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
}));
|
|
1366
|
-
const ctxAllCollapsed = this._parentContextKeyService.createKey(EditorContextKeys.multiDiffEditorAllCollapsed.key, false);
|
|
1367
|
-
this._register(autorun((reader) => {
|
|
1368
|
-
const viewModel = this._viewModel.read(reader);
|
|
1369
|
-
if (viewModel) {
|
|
1370
|
-
const allCollapsed = viewModel.items.read(reader).every(item => item.collapsed.read(reader));
|
|
1371
|
-
ctxAllCollapsed.set(allCollapsed);
|
|
1372
|
-
}
|
|
1373
|
-
}));
|
|
1374
|
-
this._register(autorun((reader) => {
|
|
1375
|
-
const lastActiveDiffItem = this.lastActiveDiffItem.read(reader);
|
|
1376
|
-
transaction(tx => {
|
|
1377
|
-
this._viewModel.read(reader)?.activeDiffItem.set(lastActiveDiffItem?.viewModel, tx);
|
|
1378
|
-
});
|
|
1379
|
-
}));
|
|
1380
|
-
this._register(autorun((reader) => {
|
|
1381
|
-
const dimension = this._dimension.read(reader);
|
|
1382
|
-
this._sizeObserver.observe(dimension);
|
|
1383
|
-
}));
|
|
1384
|
-
this._elements.content.style.position = 'relative';
|
|
1385
|
-
this._register(autorun((reader) => {
|
|
1386
|
-
const height = this._sizeObserver.height.read(reader);
|
|
1387
|
-
this._elements.root.style.height = `${height}px`;
|
|
1388
|
-
const totalHeight = this._totalHeight.read(reader);
|
|
1389
|
-
this._elements.content.style.height = `${totalHeight}px`;
|
|
1390
|
-
const width = this._sizeObserver.width.read(reader);
|
|
1391
|
-
let scrollWidth = width;
|
|
1392
|
-
const viewItems = this._viewItems.read(reader);
|
|
1393
|
-
const max = findFirstMaxBy(viewItems, i => i.maxScroll.read(reader).maxScroll);
|
|
1394
|
-
if (max) {
|
|
1395
|
-
const maxScroll = max.maxScroll.read(reader);
|
|
1396
|
-
scrollWidth = width + maxScroll.maxScroll;
|
|
1397
|
-
}
|
|
1398
|
-
this._scrollableElement.setScrollDimensions({
|
|
1399
|
-
width: width,
|
|
1400
|
-
height: height,
|
|
1401
|
-
scrollHeight: totalHeight,
|
|
1402
|
-
scrollWidth,
|
|
1403
|
-
});
|
|
1404
|
-
}));
|
|
1405
|
-
_element.replaceChildren(this._scrollableElement.getDomNode());
|
|
1406
|
-
this._register(toDisposable(() => {
|
|
1407
|
-
_element.replaceChildren();
|
|
1408
|
-
}));
|
|
1409
|
-
this._register(this._register(autorun(reader => {
|
|
1410
|
-
globalTransaction(tx => {
|
|
1411
|
-
this.render(reader);
|
|
1412
|
-
});
|
|
1413
|
-
})));
|
|
1414
|
-
}
|
|
1415
|
-
setScrollState(scrollState) {
|
|
1416
|
-
this._scrollableElement.setScrollPosition({ scrollLeft: scrollState.left, scrollTop: scrollState.top });
|
|
1417
|
-
}
|
|
1418
|
-
getViewState() {
|
|
1419
|
-
return {
|
|
1420
|
-
scrollState: {
|
|
1421
|
-
top: this.scrollTop.get(),
|
|
1422
|
-
left: this.scrollLeft.get(),
|
|
1423
|
-
},
|
|
1424
|
-
docStates: Object.fromEntries(( this._viewItems.get().map(i => [i.getKey(), i.getViewState()]))),
|
|
1425
|
-
};
|
|
1426
|
-
}
|
|
1427
|
-
setViewState(viewState) {
|
|
1428
|
-
this.setScrollState(viewState.scrollState);
|
|
1429
|
-
this._lastDocStates = viewState.docStates;
|
|
1430
|
-
transaction(tx => {
|
|
1431
|
-
if (viewState.docStates) {
|
|
1432
|
-
for (const i of this._viewItems.get()) {
|
|
1433
|
-
const state = viewState.docStates[i.getKey()];
|
|
1434
|
-
if (state) {
|
|
1435
|
-
i.setViewState(state, tx);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
tryGetCodeEditor(resource) {
|
|
1442
|
-
const item = this._viewItems.get().find(v => ( v.viewModel.diffEditorViewModel.model.modified.uri.toString()) === ( resource.toString())
|
|
1443
|
-
|| ( v.viewModel.diffEditorViewModel.model.original.uri.toString()) === ( resource.toString()));
|
|
1444
|
-
const editor = item?.template.get()?.editor;
|
|
1445
|
-
if (!editor) {
|
|
1446
|
-
return undefined;
|
|
1447
|
-
}
|
|
1448
|
-
if (( item.viewModel.diffEditorViewModel.model.modified.uri.toString()) === ( resource.toString())) {
|
|
1449
|
-
return { diffEditor: editor, editor: editor.getModifiedEditor() };
|
|
1450
|
-
}
|
|
1451
|
-
else {
|
|
1452
|
-
return { diffEditor: editor, editor: editor.getOriginalEditor() };
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
render(reader) {
|
|
1456
|
-
const scrollTop = this.scrollTop.read(reader);
|
|
1457
|
-
let contentScrollOffsetToScrollOffset = 0;
|
|
1458
|
-
let itemHeightSumBefore = 0;
|
|
1459
|
-
let itemContentHeightSumBefore = 0;
|
|
1460
|
-
const viewPortHeight = this._sizeObserver.height.read(reader);
|
|
1461
|
-
const contentViewPort = OffsetRange.ofStartAndLength(scrollTop, viewPortHeight);
|
|
1462
|
-
const width = this._sizeObserver.width.read(reader);
|
|
1463
|
-
for (const v of this._viewItems.read(reader)) {
|
|
1464
|
-
const itemContentHeight = v.contentHeight.read(reader);
|
|
1465
|
-
const itemHeight = Math.min(itemContentHeight, viewPortHeight);
|
|
1466
|
-
const itemRange = OffsetRange.ofStartAndLength(itemHeightSumBefore, itemHeight);
|
|
1467
|
-
const itemContentRange = OffsetRange.ofStartAndLength(itemContentHeightSumBefore, itemContentHeight);
|
|
1468
|
-
if (itemContentRange.isBefore(contentViewPort)) {
|
|
1469
|
-
contentScrollOffsetToScrollOffset -= itemContentHeight - itemHeight;
|
|
1470
|
-
v.hide();
|
|
1471
|
-
}
|
|
1472
|
-
else if (itemContentRange.isAfter(contentViewPort)) {
|
|
1473
|
-
v.hide();
|
|
1474
|
-
}
|
|
1475
|
-
else {
|
|
1476
|
-
const scroll = Math.max(0, Math.min(contentViewPort.start - itemContentRange.start, itemContentHeight - itemHeight));
|
|
1477
|
-
contentScrollOffsetToScrollOffset -= scroll;
|
|
1478
|
-
const viewPort = OffsetRange.ofStartAndLength(scrollTop + contentScrollOffsetToScrollOffset, viewPortHeight);
|
|
1479
|
-
v.render(itemRange, scroll, width, viewPort);
|
|
1480
|
-
}
|
|
1481
|
-
itemHeightSumBefore += itemHeight + this._spaceBetweenPx;
|
|
1482
|
-
itemContentHeightSumBefore += itemContentHeight + this._spaceBetweenPx;
|
|
1483
|
-
}
|
|
1484
|
-
this._elements.content.style.transform = `translateY(${-(scrollTop + contentScrollOffsetToScrollOffset)}px)`;
|
|
1485
|
-
}
|
|
1486
|
-
};
|
|
1487
|
-
MultiDiffEditorWidgetImpl = ( __decorate([
|
|
1488
|
-
( __param(4, IContextKeyService)),
|
|
1489
|
-
( __param(5, IInstantiationService))
|
|
1490
|
-
], MultiDiffEditorWidgetImpl));
|
|
1491
|
-
class VirtualizedViewItem extends Disposable {
|
|
1492
|
-
constructor(viewModel, _objectPool, _scrollLeft) {
|
|
1493
|
-
super();
|
|
1494
|
-
this.viewModel = viewModel;
|
|
1495
|
-
this._objectPool = _objectPool;
|
|
1496
|
-
this._scrollLeft = _scrollLeft;
|
|
1497
|
-
this._templateRef = this._register(disposableObservableValue(this, undefined));
|
|
1498
|
-
this.contentHeight = derived(this, reader => this._templateRef.read(reader)?.object.contentHeight?.read(reader) ?? this.viewModel.lastTemplateData.read(reader).contentHeight);
|
|
1499
|
-
this.maxScroll = derived(this, reader => this._templateRef.read(reader)?.object.maxScroll.read(reader) ?? { maxScroll: 0, scrollWidth: 0 });
|
|
1500
|
-
this.template = derived(this, reader => this._templateRef.read(reader)?.object);
|
|
1501
|
-
this._isHidden = observableValue(this, false);
|
|
1502
|
-
this._register(autorun((reader) => {
|
|
1503
|
-
const scrollLeft = this._scrollLeft.read(reader);
|
|
1504
|
-
this._templateRef.read(reader)?.object.setScrollLeft(scrollLeft);
|
|
1505
|
-
}));
|
|
1506
|
-
this._register(autorun(reader => {
|
|
1507
|
-
const ref = this._templateRef.read(reader);
|
|
1508
|
-
if (!ref) {
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
const isHidden = this._isHidden.read(reader);
|
|
1512
|
-
if (!isHidden) {
|
|
1513
|
-
return;
|
|
1514
|
-
}
|
|
1515
|
-
const isFocused = ref.object.isFocused.read(reader);
|
|
1516
|
-
if (isFocused) {
|
|
1517
|
-
return;
|
|
1518
|
-
}
|
|
1519
|
-
this._clear();
|
|
1520
|
-
}));
|
|
1521
|
-
}
|
|
1522
|
-
dispose() {
|
|
1523
|
-
this._clear();
|
|
1524
|
-
super.dispose();
|
|
1525
|
-
}
|
|
1526
|
-
toString() {
|
|
1527
|
-
return `VirtualViewItem(${this.viewModel.entry.value.modified?.uri.toString()})`;
|
|
1528
|
-
}
|
|
1529
|
-
getKey() {
|
|
1530
|
-
return this.viewModel.getKey();
|
|
1531
|
-
}
|
|
1532
|
-
getViewState() {
|
|
1533
|
-
transaction(tx => {
|
|
1534
|
-
this._updateTemplateData(tx);
|
|
1535
|
-
});
|
|
1536
|
-
return {
|
|
1537
|
-
collapsed: this.viewModel.collapsed.get(),
|
|
1538
|
-
selections: this.viewModel.lastTemplateData.get().selections,
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
setViewState(viewState, tx) {
|
|
1542
|
-
this.viewModel.collapsed.set(viewState.collapsed, tx);
|
|
1543
|
-
this._updateTemplateData(tx);
|
|
1544
|
-
const data = this.viewModel.lastTemplateData.get();
|
|
1545
|
-
const selections = viewState.selections?.map(Selection$1.liftSelection);
|
|
1546
|
-
this.viewModel.lastTemplateData.set({
|
|
1547
|
-
...data,
|
|
1548
|
-
selections,
|
|
1549
|
-
}, tx);
|
|
1550
|
-
const ref = this._templateRef.get();
|
|
1551
|
-
if (ref) {
|
|
1552
|
-
if (selections) {
|
|
1553
|
-
ref.object.editor.setSelections(selections);
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
_updateTemplateData(tx) {
|
|
1558
|
-
const ref = this._templateRef.get();
|
|
1559
|
-
if (!ref) {
|
|
1560
|
-
return;
|
|
1561
|
-
}
|
|
1562
|
-
this.viewModel.lastTemplateData.set({
|
|
1563
|
-
contentHeight: ref.object.contentHeight.get(),
|
|
1564
|
-
selections: ref.object.editor.getSelections() ?? undefined,
|
|
1565
|
-
}, tx);
|
|
1566
|
-
}
|
|
1567
|
-
_clear() {
|
|
1568
|
-
const ref = this._templateRef.get();
|
|
1569
|
-
if (!ref) {
|
|
1570
|
-
return;
|
|
1571
|
-
}
|
|
1572
|
-
transaction(tx => {
|
|
1573
|
-
this._updateTemplateData(tx);
|
|
1574
|
-
ref.object.hide();
|
|
1575
|
-
this._templateRef.set(undefined, tx);
|
|
1576
|
-
});
|
|
1577
|
-
}
|
|
1578
|
-
hide() {
|
|
1579
|
-
this._isHidden.set(true, undefined);
|
|
1580
|
-
}
|
|
1581
|
-
render(verticalSpace, offset, width, viewPort) {
|
|
1582
|
-
this._isHidden.set(false, undefined);
|
|
1583
|
-
let ref = this._templateRef.get();
|
|
1584
|
-
if (!ref) {
|
|
1585
|
-
ref = this._objectPool.getUnusedObj(( new TemplateData(this.viewModel)));
|
|
1586
|
-
this._templateRef.set(ref, undefined);
|
|
1587
|
-
const selections = this.viewModel.lastTemplateData.get().selections;
|
|
1588
|
-
if (selections) {
|
|
1589
|
-
ref.object.editor.setSelections(selections);
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
ref.object.render(verticalSpace, width, offset, viewPort);
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
class MultiDiffEditorViewModel extends Disposable {
|
|
1597
|
-
async waitForDiffs() {
|
|
1598
|
-
for (const d of this.items.get()) {
|
|
1599
|
-
await d.diffEditorViewModel.waitForDiff();
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
collapseAll() {
|
|
1603
|
-
transaction(tx => {
|
|
1604
|
-
for (const d of this.items.get()) {
|
|
1605
|
-
d.collapsed.set(true, tx);
|
|
1606
|
-
}
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
|
-
expandAll() {
|
|
1610
|
-
transaction(tx => {
|
|
1611
|
-
for (const d of this.items.get()) {
|
|
1612
|
-
d.collapsed.set(false, tx);
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
1615
|
-
}
|
|
1616
|
-
get contextKeys() {
|
|
1617
|
-
return this.model.contextKeys;
|
|
1618
|
-
}
|
|
1619
|
-
constructor(model, _instantiationService) {
|
|
1620
|
-
super();
|
|
1621
|
-
this.model = model;
|
|
1622
|
-
this._instantiationService = _instantiationService;
|
|
1623
|
-
this._documents = observableFromEvent(this.model.onDidChange, () => this.model.documents);
|
|
1624
|
-
this.items = mapObservableArrayCached(this, this._documents, (d, store) => store.add(this._instantiationService.createInstance(DocumentDiffItemViewModel, d)))
|
|
1625
|
-
.recomputeInitiallyAndOnChange(this._store);
|
|
1626
|
-
this.activeDiffItem = observableValue(this, undefined);
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
let DocumentDiffItemViewModel = class DocumentDiffItemViewModel extends Disposable {
|
|
1630
|
-
get originalUri() { return this.entry.value.original?.uri; }
|
|
1631
|
-
get modifiedUri() { return this.entry.value.modified?.uri; }
|
|
1632
|
-
constructor(entry, _instantiationService, _modelService) {
|
|
1633
|
-
super();
|
|
1634
|
-
this.entry = entry;
|
|
1635
|
-
this._instantiationService = _instantiationService;
|
|
1636
|
-
this._modelService = _modelService;
|
|
1637
|
-
this.collapsed = observableValue(this, false);
|
|
1638
|
-
this.lastTemplateData = observableValue(this, { contentHeight: 500, selections: undefined, });
|
|
1639
|
-
function updateOptions(options) {
|
|
1640
|
-
return {
|
|
1641
|
-
...options,
|
|
1642
|
-
hideUnchangedRegions: {
|
|
1643
|
-
enabled: true,
|
|
1644
|
-
},
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
const options = ( new DiffEditorOptions(updateOptions(this.entry.value.options || {})));
|
|
1648
|
-
if (this.entry.value.onOptionsDidChange) {
|
|
1649
|
-
this._register(this.entry.value.onOptionsDidChange(() => {
|
|
1650
|
-
options.updateOptions(updateOptions(this.entry.value.options || {}));
|
|
1651
|
-
}));
|
|
1652
|
-
}
|
|
1653
|
-
const originalTextModel = this.entry.value.original ?? this._register(this._modelService.createModel('', null));
|
|
1654
|
-
const modifiedTextModel = this.entry.value.modified ?? this._register(this._modelService.createModel('', null));
|
|
1655
|
-
this.diffEditorViewModel = this._register(this._instantiationService.createInstance(DiffEditorViewModel, {
|
|
1656
|
-
original: originalTextModel,
|
|
1657
|
-
modified: modifiedTextModel,
|
|
1658
|
-
}, options));
|
|
1659
|
-
}
|
|
1660
|
-
getKey() {
|
|
1661
|
-
return JSON.stringify([
|
|
1662
|
-
this.originalUri?.toString(),
|
|
1663
|
-
this.modifiedUri?.toString()
|
|
1664
|
-
]);
|
|
1665
|
-
}
|
|
1666
|
-
};
|
|
1667
|
-
DocumentDiffItemViewModel = ( __decorate([
|
|
1668
|
-
( __param(1, IInstantiationService)),
|
|
1669
|
-
( __param(2, IModelService))
|
|
1670
|
-
], DocumentDiffItemViewModel));
|
|
1671
|
-
|
|
1672
|
-
registerColor('multiDiffEditor.headerBackground', { dark: '#808080', light: '#b4b4b4', hcDark: '#808080', hcLight: '#b4b4b4', }, ( localizeWithPath(
|
|
1673
|
-
'vs/editor/browser/widget/multiDiffEditorWidget/colors',
|
|
1674
|
-
'multiDiffEditor.headerBackground',
|
|
1675
|
-
'The background color of the diff editor\'s header'
|
|
1676
|
-
)));
|
|
1677
|
-
registerColor('multiDiffEditor.background', { dark: '#000000', light: '#e5e5e5', hcDark: '#000000', hcLight: '#e5e5e5', }, ( localizeWithPath(
|
|
1678
|
-
'vs/editor/browser/widget/multiDiffEditorWidget/colors',
|
|
1679
|
-
'multiDiffEditor.background',
|
|
1680
|
-
'The background color of the multi file diff editor'
|
|
1681
|
-
)));
|
|
1682
|
-
registerColor('multiDiffEditor.border', { dark: 'sideBarSectionHeader.border', light: '#cccccc', hcDark: 'sideBarSectionHeader.border', hcLight: '#cccccc', }, ( localizeWithPath(
|
|
1683
|
-
'vs/editor/browser/widget/multiDiffEditorWidget/colors',
|
|
1684
|
-
'multiDiffEditor.border',
|
|
1685
|
-
'The border color of the multi file diff editor'
|
|
1686
|
-
)));
|
|
1687
|
-
|
|
1688
|
-
let MultiDiffEditorWidget = class MultiDiffEditorWidget extends Disposable {
|
|
1689
|
-
constructor(_element, _workbenchUIElementFactory, _instantiationService) {
|
|
1690
|
-
super();
|
|
1691
|
-
this._element = _element;
|
|
1692
|
-
this._workbenchUIElementFactory = _workbenchUIElementFactory;
|
|
1693
|
-
this._instantiationService = _instantiationService;
|
|
1694
|
-
this._dimension = observableValue(this, undefined);
|
|
1695
|
-
this._viewModel = observableValue(this, undefined);
|
|
1696
|
-
this._widgetImpl = derivedWithStore(this, (reader, store) => {
|
|
1697
|
-
readHotReloadableExport(DiffEditorItemTemplate, reader);
|
|
1698
|
-
return store.add(this._instantiationService.createInstance((readHotReloadableExport(MultiDiffEditorWidgetImpl, reader)), this._element, this._dimension, this._viewModel, this._workbenchUIElementFactory));
|
|
1699
|
-
});
|
|
1700
|
-
this._activeControl = derived(this, (reader) => this._widgetImpl.read(reader).activeControl.read(reader));
|
|
1701
|
-
this.onDidChangeActiveControl = Event.fromObservableLight(this._activeControl);
|
|
1702
|
-
this._register(recomputeInitiallyAndOnChange(this._widgetImpl));
|
|
1703
|
-
}
|
|
1704
|
-
createViewModel(model) {
|
|
1705
|
-
return ( new MultiDiffEditorViewModel(model, this._instantiationService));
|
|
1706
|
-
}
|
|
1707
|
-
setViewModel(viewModel) {
|
|
1708
|
-
this._viewModel.set(viewModel, undefined);
|
|
1709
|
-
}
|
|
1710
|
-
layout(dimension) {
|
|
1711
|
-
this._dimension.set(dimension, undefined);
|
|
1712
|
-
}
|
|
1713
|
-
getActiveControl() {
|
|
1714
|
-
return this._activeControl.get();
|
|
1715
|
-
}
|
|
1716
|
-
getViewState() {
|
|
1717
|
-
return this._widgetImpl.get().getViewState();
|
|
1718
|
-
}
|
|
1719
|
-
setViewState(viewState) {
|
|
1720
|
-
this._widgetImpl.get().setViewState(viewState);
|
|
1721
|
-
}
|
|
1722
|
-
tryGetCodeEditor(resource) {
|
|
1723
|
-
return this._widgetImpl.get().tryGetCodeEditor(resource);
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
MultiDiffEditorWidget = ( __decorate([
|
|
1727
|
-
( __param(2, IInstantiationService))
|
|
1728
|
-
], MultiDiffEditorWidget));
|
|
1729
|
-
|
|
1730
1005
|
function create(domElement, options, override) {
|
|
1731
1006
|
const instantiationService = StandaloneServices.initialize(override || {});
|
|
1732
1007
|
return instantiationService.createInstance(StandaloneEditor, domElement, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-editor-api",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.0-next.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
"module": "esm/vs/editor/editor.api.js",
|
|
19
19
|
"types": "esm/vs/editor/editor.api.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@2.1
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@2.2.0-next.1"
|
|
22
22
|
}
|
|
23
23
|
}
|