@codingame/monaco-vscode-views-service-override 1.85.0 → 1.85.2
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/index-no-csp.html +4 -0
- package/assets/index.html +5 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +11 -9
- package/tools/editor.js +1 -1
- package/views.d.ts +9 -4
- package/views.js +32 -10
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +2 -2
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +1 -1
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +692 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +240 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +77 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +71 -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 +145 -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 +196 -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 +611 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +158 -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 +173 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +79 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +1 -1
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +3 -0
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -3
- package/vscode/src/vs/base/browser/ui/tree/treeDefaults.js +0 -16
- package/vscode/src/vs/workbench/browser/parts/views/checkbox.js +0 -107
- package/vscode/src/vs/workbench/browser/parts/views/media/views.css.js +0 -6
- package/vscode/src/vs/workbench/browser/parts/views/treeView.js +0 -1604
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +0 -390
- package/vscode/src/vs/workbench/contrib/languageDetection/browser/languageDetection.contribution.js +0 -157
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +0 -5
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +0 -217
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +0 -91
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +0 -1837
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { createStyleSheet, isInShadowDOM, h, $, reset } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
2
|
+
import { renderLabelWithIcons } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
|
|
3
|
+
import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
|
|
4
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
5
|
+
import { derived, transaction, autorun } from 'monaco-editor/esm/vs/base/common/observable.js';
|
|
6
|
+
import { EDITOR_FONT_DEFAULTS } from 'monaco-editor/esm/vs/editor/common/config/editorOptions.js';
|
|
7
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
+
import { ModifiedBaseRangeStateKind, ModifiedBaseRangeState } from 'vscode/vscode/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange';
|
|
9
|
+
import { FixedZoneWidget } from './fixedZoneWidget.js';
|
|
10
|
+
|
|
11
|
+
class ConflictActionsFactory extends Disposable {
|
|
12
|
+
constructor(_editor) {
|
|
13
|
+
super();
|
|
14
|
+
this._editor = _editor;
|
|
15
|
+
this._register(this._editor.onDidChangeConfiguration((e) => {
|
|
16
|
+
if (e.hasChanged(50 ) || e.hasChanged(19 ) || e.hasChanged(18 )) {
|
|
17
|
+
this._updateLensStyle();
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
this._styleClassName = '_conflictActionsFactory_' + ( hash(this._editor.getId()).toString(16));
|
|
21
|
+
this._styleElement = createStyleSheet(isInShadowDOM(this._editor.getContainerDomNode())
|
|
22
|
+
? this._editor.getContainerDomNode()
|
|
23
|
+
: undefined, undefined, this._store);
|
|
24
|
+
this._updateLensStyle();
|
|
25
|
+
}
|
|
26
|
+
_updateLensStyle() {
|
|
27
|
+
const { codeLensHeight, fontSize } = this._getLayoutInfo();
|
|
28
|
+
const fontFamily = this._editor.getOption(18 );
|
|
29
|
+
const editorFontInfo = this._editor.getOption(50 );
|
|
30
|
+
const fontFamilyVar = `--codelens-font-family${this._styleClassName}`;
|
|
31
|
+
const fontFeaturesVar = `--codelens-font-features${this._styleClassName}`;
|
|
32
|
+
let newStyle = `
|
|
33
|
+
.${this._styleClassName} { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; padding-right: ${Math.round(fontSize * 0.5)}px; font-feature-settings: var(${fontFeaturesVar}) }
|
|
34
|
+
.monaco-workbench .${this._styleClassName} span.codicon { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; }
|
|
35
|
+
`;
|
|
36
|
+
if (fontFamily) {
|
|
37
|
+
newStyle += `${this._styleClassName} { font-family: var(${fontFamilyVar}), ${EDITOR_FONT_DEFAULTS.fontFamily}}`;
|
|
38
|
+
}
|
|
39
|
+
this._styleElement.textContent = newStyle;
|
|
40
|
+
this._editor.getContainerDomNode().style.setProperty(fontFamilyVar, fontFamily ?? 'inherit');
|
|
41
|
+
this._editor.getContainerDomNode().style.setProperty(fontFeaturesVar, editorFontInfo.fontFeatureSettings);
|
|
42
|
+
}
|
|
43
|
+
_getLayoutInfo() {
|
|
44
|
+
const lineHeightFactor = Math.max(1.3, this._editor.getOption(66 ) / this._editor.getOption(52 ));
|
|
45
|
+
let fontSize = this._editor.getOption(19 );
|
|
46
|
+
if (!fontSize || fontSize < 5) {
|
|
47
|
+
fontSize = (this._editor.getOption(52 ) * .9) | 0;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
fontSize,
|
|
51
|
+
codeLensHeight: (fontSize * lineHeightFactor) | 0,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
createWidget(viewZoneChangeAccessor, lineNumber, items, viewZoneIdsToCleanUp) {
|
|
55
|
+
const layoutInfo = this._getLayoutInfo();
|
|
56
|
+
return ( new ActionsContentWidget(
|
|
57
|
+
this._editor,
|
|
58
|
+
viewZoneChangeAccessor,
|
|
59
|
+
lineNumber,
|
|
60
|
+
layoutInfo.codeLensHeight + 2,
|
|
61
|
+
this._styleClassName,
|
|
62
|
+
items,
|
|
63
|
+
viewZoneIdsToCleanUp
|
|
64
|
+
));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class ActionsSource {
|
|
68
|
+
constructor(viewModel, modifiedBaseRange) {
|
|
69
|
+
this.viewModel = viewModel;
|
|
70
|
+
this.modifiedBaseRange = modifiedBaseRange;
|
|
71
|
+
this.itemsInput1 = this.getItemsInput(1);
|
|
72
|
+
this.itemsInput2 = this.getItemsInput(2);
|
|
73
|
+
this.resultItems = derived(this, reader => {
|
|
74
|
+
const viewModel = this.viewModel;
|
|
75
|
+
const modifiedBaseRange = this.modifiedBaseRange;
|
|
76
|
+
const state = viewModel.model.getState(modifiedBaseRange).read(reader);
|
|
77
|
+
const model = viewModel.model;
|
|
78
|
+
const result = [];
|
|
79
|
+
if (state.kind === ModifiedBaseRangeStateKind.unrecognized) {
|
|
80
|
+
result.push({
|
|
81
|
+
text: ( localizeWithPath(
|
|
82
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
83
|
+
'manualResolution',
|
|
84
|
+
"Manual Resolution"
|
|
85
|
+
)),
|
|
86
|
+
tooltip: ( localizeWithPath(
|
|
87
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
88
|
+
'manualResolutionTooltip',
|
|
89
|
+
"This conflict has been resolved manually."
|
|
90
|
+
)),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else if (state.kind === ModifiedBaseRangeStateKind.base) {
|
|
94
|
+
result.push({
|
|
95
|
+
text: ( localizeWithPath(
|
|
96
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
97
|
+
'noChangesAccepted',
|
|
98
|
+
'No Changes Accepted'
|
|
99
|
+
)),
|
|
100
|
+
tooltip: ( localizeWithPath(
|
|
101
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
102
|
+
'noChangesAcceptedTooltip',
|
|
103
|
+
'The current resolution of this conflict equals the common ancestor of both the right and left changes.'
|
|
104
|
+
)),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const labels = [];
|
|
109
|
+
if (state.includesInput1) {
|
|
110
|
+
labels.push(model.input1.title);
|
|
111
|
+
}
|
|
112
|
+
if (state.includesInput2) {
|
|
113
|
+
labels.push(model.input2.title);
|
|
114
|
+
}
|
|
115
|
+
if (state.kind === ModifiedBaseRangeStateKind.both && state.firstInput === 2) {
|
|
116
|
+
labels.reverse();
|
|
117
|
+
}
|
|
118
|
+
result.push({
|
|
119
|
+
text: `${labels.join(' + ')}`
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const stateToggles = [];
|
|
123
|
+
if (state.includesInput1) {
|
|
124
|
+
stateToggles.push(command(( localizeWithPath(
|
|
125
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
126
|
+
'remove',
|
|
127
|
+
'Remove {0}',
|
|
128
|
+
model.input1.title
|
|
129
|
+
)), async () => {
|
|
130
|
+
transaction((tx) => {
|
|
131
|
+
model.setState(modifiedBaseRange, state.withInputValue(1, false), true, tx);
|
|
132
|
+
model.telemetry.reportRemoveInvoked(1, state.includesInput(2));
|
|
133
|
+
});
|
|
134
|
+
}, ( localizeWithPath(
|
|
135
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
136
|
+
'removeTooltip',
|
|
137
|
+
'Remove {0} from the result document.',
|
|
138
|
+
model.input1.title
|
|
139
|
+
))));
|
|
140
|
+
}
|
|
141
|
+
if (state.includesInput2) {
|
|
142
|
+
stateToggles.push(command(( localizeWithPath(
|
|
143
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
144
|
+
'remove',
|
|
145
|
+
'Remove {0}',
|
|
146
|
+
model.input2.title
|
|
147
|
+
)), async () => {
|
|
148
|
+
transaction((tx) => {
|
|
149
|
+
model.setState(modifiedBaseRange, state.withInputValue(2, false), true, tx);
|
|
150
|
+
model.telemetry.reportRemoveInvoked(2, state.includesInput(1));
|
|
151
|
+
});
|
|
152
|
+
}, ( localizeWithPath(
|
|
153
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
154
|
+
'removeTooltip',
|
|
155
|
+
'Remove {0} from the result document.',
|
|
156
|
+
model.input2.title
|
|
157
|
+
))));
|
|
158
|
+
}
|
|
159
|
+
if (state.kind === ModifiedBaseRangeStateKind.both &&
|
|
160
|
+
state.firstInput === 2) {
|
|
161
|
+
stateToggles.reverse();
|
|
162
|
+
}
|
|
163
|
+
result.push(...stateToggles);
|
|
164
|
+
if (state.kind === ModifiedBaseRangeStateKind.unrecognized) {
|
|
165
|
+
result.push(command(( localizeWithPath(
|
|
166
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
167
|
+
'resetToBase',
|
|
168
|
+
'Reset to base'
|
|
169
|
+
)), async () => {
|
|
170
|
+
transaction((tx) => {
|
|
171
|
+
model.setState(modifiedBaseRange, ModifiedBaseRangeState.base, true, tx);
|
|
172
|
+
model.telemetry.reportResetToBaseInvoked();
|
|
173
|
+
});
|
|
174
|
+
}, ( localizeWithPath(
|
|
175
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
176
|
+
'resetToBaseTooltip',
|
|
177
|
+
'Reset this conflict to the common ancestor of both the right and left changes.'
|
|
178
|
+
))));
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
});
|
|
182
|
+
this.isEmpty = derived(this, reader => {
|
|
183
|
+
return this.itemsInput1.read(reader).length + this.itemsInput2.read(reader).length + this.resultItems.read(reader).length === 0;
|
|
184
|
+
});
|
|
185
|
+
this.inputIsEmpty = derived(this, reader => {
|
|
186
|
+
return this.itemsInput1.read(reader).length + this.itemsInput2.read(reader).length === 0;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
getItemsInput(inputNumber) {
|
|
190
|
+
return derived(reader => {
|
|
191
|
+
const viewModel = this.viewModel;
|
|
192
|
+
const modifiedBaseRange = this.modifiedBaseRange;
|
|
193
|
+
if (!viewModel.model.hasBaseRange(modifiedBaseRange)) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
const state = viewModel.model.getState(modifiedBaseRange).read(reader);
|
|
197
|
+
const handled = viewModel.model.isHandled(modifiedBaseRange).read(reader);
|
|
198
|
+
const model = viewModel.model;
|
|
199
|
+
const result = [];
|
|
200
|
+
const inputData = inputNumber === 1 ? viewModel.model.input1 : viewModel.model.input2;
|
|
201
|
+
const showNonConflictingChanges = viewModel.showNonConflictingChanges.read(reader);
|
|
202
|
+
if (!modifiedBaseRange.isConflicting && handled && !showNonConflictingChanges) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
const otherInputNumber = inputNumber === 1 ? 2 : 1;
|
|
206
|
+
if (state.kind !== ModifiedBaseRangeStateKind.unrecognized && !state.isInputIncluded(inputNumber)) {
|
|
207
|
+
if (!state.isInputIncluded(otherInputNumber) || !this.viewModel.shouldUseAppendInsteadOfAccept.read(reader)) {
|
|
208
|
+
result.push(command(( localizeWithPath(
|
|
209
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
210
|
+
'accept',
|
|
211
|
+
"Accept {0}",
|
|
212
|
+
inputData.title
|
|
213
|
+
)), async () => {
|
|
214
|
+
transaction((tx) => {
|
|
215
|
+
model.setState(modifiedBaseRange, state.withInputValue(inputNumber, true, false), inputNumber, tx);
|
|
216
|
+
model.telemetry.reportAcceptInvoked(inputNumber, state.includesInput(otherInputNumber));
|
|
217
|
+
});
|
|
218
|
+
}, ( localizeWithPath(
|
|
219
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
220
|
+
'acceptTooltip',
|
|
221
|
+
"Accept {0} in the result document.",
|
|
222
|
+
inputData.title
|
|
223
|
+
))));
|
|
224
|
+
if (modifiedBaseRange.canBeCombined) {
|
|
225
|
+
const commandName = modifiedBaseRange.isOrderRelevant
|
|
226
|
+
? ( localizeWithPath(
|
|
227
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
228
|
+
'acceptBoth0First',
|
|
229
|
+
"Accept Combination ({0} First)",
|
|
230
|
+
inputData.title
|
|
231
|
+
))
|
|
232
|
+
: ( localizeWithPath(
|
|
233
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
234
|
+
'acceptBoth',
|
|
235
|
+
"Accept Combination"
|
|
236
|
+
));
|
|
237
|
+
result.push(command(commandName, async () => {
|
|
238
|
+
transaction((tx) => {
|
|
239
|
+
model.setState(modifiedBaseRange, ModifiedBaseRangeState.base
|
|
240
|
+
.withInputValue(inputNumber, true)
|
|
241
|
+
.withInputValue(otherInputNumber, true, true), true, tx);
|
|
242
|
+
model.telemetry.reportSmartCombinationInvoked(state.includesInput(otherInputNumber));
|
|
243
|
+
});
|
|
244
|
+
}, ( localizeWithPath(
|
|
245
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
246
|
+
'acceptBothTooltip',
|
|
247
|
+
"Accept an automatic combination of both sides in the result document."
|
|
248
|
+
))));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
result.push(command(( localizeWithPath(
|
|
253
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
254
|
+
'append',
|
|
255
|
+
"Append {0}",
|
|
256
|
+
inputData.title
|
|
257
|
+
)), async () => {
|
|
258
|
+
transaction((tx) => {
|
|
259
|
+
model.setState(modifiedBaseRange, state.withInputValue(inputNumber, true, false), inputNumber, tx);
|
|
260
|
+
model.telemetry.reportAcceptInvoked(inputNumber, state.includesInput(otherInputNumber));
|
|
261
|
+
});
|
|
262
|
+
}, ( localizeWithPath(
|
|
263
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
264
|
+
'appendTooltip',
|
|
265
|
+
"Append {0} to the result document.",
|
|
266
|
+
inputData.title
|
|
267
|
+
))));
|
|
268
|
+
if (modifiedBaseRange.canBeCombined) {
|
|
269
|
+
result.push(command(( localizeWithPath(
|
|
270
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
271
|
+
'combine',
|
|
272
|
+
"Accept Combination",
|
|
273
|
+
inputData.title
|
|
274
|
+
)), async () => {
|
|
275
|
+
transaction((tx) => {
|
|
276
|
+
model.setState(modifiedBaseRange, state.withInputValue(inputNumber, true, true), inputNumber, tx);
|
|
277
|
+
model.telemetry.reportSmartCombinationInvoked(state.includesInput(otherInputNumber));
|
|
278
|
+
});
|
|
279
|
+
}, ( localizeWithPath(
|
|
280
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
281
|
+
'acceptBothTooltip',
|
|
282
|
+
"Accept an automatic combination of both sides in the result document."
|
|
283
|
+
))));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (!model.isInputHandled(modifiedBaseRange, inputNumber).read(reader)) {
|
|
287
|
+
result.push(command(( localizeWithPath(
|
|
288
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
289
|
+
'ignore',
|
|
290
|
+
'Ignore'
|
|
291
|
+
)), async () => {
|
|
292
|
+
transaction((tx) => {
|
|
293
|
+
model.setInputHandled(modifiedBaseRange, inputNumber, true, tx);
|
|
294
|
+
});
|
|
295
|
+
}, ( localizeWithPath(
|
|
296
|
+
'vs/workbench/contrib/mergeEditor/browser/view/conflictActions',
|
|
297
|
+
'markAsHandledTooltip',
|
|
298
|
+
"Don't take this side of the conflict."
|
|
299
|
+
))));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function command(title, action, tooltip) {
|
|
307
|
+
return {
|
|
308
|
+
text: title,
|
|
309
|
+
action,
|
|
310
|
+
tooltip,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
class ActionsContentWidget extends FixedZoneWidget {
|
|
314
|
+
constructor(editor, viewZoneAccessor, afterLineNumber, height, className, items, viewZoneIdsToCleanUp) {
|
|
315
|
+
super(editor, viewZoneAccessor, afterLineNumber, height, viewZoneIdsToCleanUp);
|
|
316
|
+
this._domNode = h('div.merge-editor-conflict-actions').root;
|
|
317
|
+
this.widgetDomNode.appendChild(this._domNode);
|
|
318
|
+
this._domNode.classList.add(className);
|
|
319
|
+
this._register(autorun(reader => {
|
|
320
|
+
const i = items.read(reader);
|
|
321
|
+
this.setState(i);
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
setState(items) {
|
|
325
|
+
const children = [];
|
|
326
|
+
let isFirst = true;
|
|
327
|
+
for (const item of items) {
|
|
328
|
+
if (isFirst) {
|
|
329
|
+
isFirst = false;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
children.push($('span', undefined, '\u00a0|\u00a0'));
|
|
333
|
+
}
|
|
334
|
+
const title = renderLabelWithIcons(item.text);
|
|
335
|
+
if (item.action) {
|
|
336
|
+
children.push($('a', { title: item.tooltip, role: 'button', onclick: () => item.action() }, ...title));
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
children.push($('span', { title: item.tooltip }, ...title));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
reset(this._domNode, ...children);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export { ActionsSource, ConflictActionsFactory };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { h, reset } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
2
|
+
import { Disposable, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
|
+
import { observableFromEvent, observableSignalFromEvent, observableSignal, transaction, autorun } from 'monaco-editor/esm/vs/base/common/observable.js';
|
|
4
|
+
import { LineRange } from 'vscode/vscode/vs/workbench/contrib/mergeEditor/browser/model/lineRange';
|
|
5
|
+
|
|
6
|
+
class EditorGutter extends Disposable {
|
|
7
|
+
constructor(_editor, _domNode, itemProvider) {
|
|
8
|
+
super();
|
|
9
|
+
this._editor = _editor;
|
|
10
|
+
this._domNode = _domNode;
|
|
11
|
+
this.itemProvider = itemProvider;
|
|
12
|
+
this.scrollTop = observableFromEvent(this._editor.onDidScrollChange, (e) => this._editor.getScrollTop());
|
|
13
|
+
this.isScrollTopZero = ( this.scrollTop.map((scrollTop) => scrollTop === 0));
|
|
14
|
+
this.modelAttached = observableFromEvent(this._editor.onDidChangeModel, (e) => this._editor.hasModel());
|
|
15
|
+
this.editorOnDidChangeViewZones = observableSignalFromEvent('onDidChangeViewZones', this._editor.onDidChangeViewZones);
|
|
16
|
+
this.editorOnDidContentSizeChange = observableSignalFromEvent('onDidContentSizeChange', this._editor.onDidContentSizeChange);
|
|
17
|
+
this.domNodeSizeChanged = observableSignal('domNodeSizeChanged');
|
|
18
|
+
this.views = ( new Map());
|
|
19
|
+
this._domNode.className = 'gutter monaco-editor';
|
|
20
|
+
const scrollDecoration = this._domNode.appendChild(h('div.scroll-decoration', { role: 'presentation', ariaHidden: 'true', style: { width: '100%' } })
|
|
21
|
+
.root);
|
|
22
|
+
const o = ( new ResizeObserver(() => {
|
|
23
|
+
transaction(tx => {
|
|
24
|
+
this.domNodeSizeChanged.trigger(tx);
|
|
25
|
+
});
|
|
26
|
+
}));
|
|
27
|
+
o.observe(this._domNode);
|
|
28
|
+
this._register(toDisposable(() => o.disconnect()));
|
|
29
|
+
this._register(autorun(reader => {
|
|
30
|
+
scrollDecoration.className = this.isScrollTopZero.read(reader) ? '' : 'scroll-decoration';
|
|
31
|
+
}));
|
|
32
|
+
this._register(autorun(reader => this.render(reader)));
|
|
33
|
+
}
|
|
34
|
+
dispose() {
|
|
35
|
+
super.dispose();
|
|
36
|
+
reset(this._domNode);
|
|
37
|
+
}
|
|
38
|
+
render(reader) {
|
|
39
|
+
if (!this.modelAttached.read(reader)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.domNodeSizeChanged.read(reader);
|
|
43
|
+
this.editorOnDidChangeViewZones.read(reader);
|
|
44
|
+
this.editorOnDidContentSizeChange.read(reader);
|
|
45
|
+
const scrollTop = this.scrollTop.read(reader);
|
|
46
|
+
const visibleRanges = this._editor.getVisibleRanges();
|
|
47
|
+
const unusedIds = ( new Set(( this.views.keys())));
|
|
48
|
+
if (visibleRanges.length > 0) {
|
|
49
|
+
const visibleRange = visibleRanges[0];
|
|
50
|
+
const visibleRange2 = ( new LineRange(
|
|
51
|
+
visibleRange.startLineNumber,
|
|
52
|
+
visibleRange.endLineNumber - visibleRange.startLineNumber
|
|
53
|
+
)).deltaEnd(1);
|
|
54
|
+
const gutterItems = this.itemProvider.getIntersectingGutterItems(visibleRange2, reader);
|
|
55
|
+
for (const gutterItem of gutterItems) {
|
|
56
|
+
if (!gutterItem.range.touches(visibleRange2)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
unusedIds.delete(gutterItem.id);
|
|
60
|
+
let view = this.views.get(gutterItem.id);
|
|
61
|
+
if (!view) {
|
|
62
|
+
const viewDomNode = document.createElement('div');
|
|
63
|
+
this._domNode.appendChild(viewDomNode);
|
|
64
|
+
const itemView = this.itemProvider.createView(gutterItem, viewDomNode);
|
|
65
|
+
view = ( new ManagedGutterItemView(itemView, viewDomNode));
|
|
66
|
+
this.views.set(gutterItem.id, view);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
view.gutterItemView.update(gutterItem);
|
|
70
|
+
}
|
|
71
|
+
const top = gutterItem.range.startLineNumber <= this._editor.getModel().getLineCount()
|
|
72
|
+
? this._editor.getTopForLineNumber(gutterItem.range.startLineNumber, true) - scrollTop
|
|
73
|
+
: this._editor.getBottomForLineNumber(gutterItem.range.startLineNumber - 1, false) - scrollTop;
|
|
74
|
+
const bottom = this._editor.getBottomForLineNumber(gutterItem.range.endLineNumberExclusive - 1, true) - scrollTop;
|
|
75
|
+
const height = bottom - top;
|
|
76
|
+
view.domNode.style.top = `${top}px`;
|
|
77
|
+
view.domNode.style.height = `${height}px`;
|
|
78
|
+
view.gutterItemView.layout(top, height, 0, this._domNode.clientHeight);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const id of unusedIds) {
|
|
82
|
+
const view = this.views.get(id);
|
|
83
|
+
view.gutterItemView.dispose();
|
|
84
|
+
this._domNode.removeChild(view.domNode);
|
|
85
|
+
this.views.delete(id);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class ManagedGutterItemView {
|
|
90
|
+
constructor(gutterItemView, domNode) {
|
|
91
|
+
this.gutterItemView = gutterItemView;
|
|
92
|
+
this.domNode = domNode;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { EditorGutter };
|
package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { reset, h } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
3
|
+
import { renderLabelWithIcons } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabels.js';
|
|
4
|
+
import { BugIndicatingError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
5
|
+
import { derived, autorunWithStore, autorun } from 'monaco-editor/esm/vs/base/common/observable.js';
|
|
6
|
+
import { MinimapPosition, OverviewRulerLane } from 'monaco-editor/esm/vs/editor/common/model.js';
|
|
7
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
+
import { MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
9
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
10
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
11
|
+
import { applyObservableDecorations } from 'vscode/vscode/vs/workbench/contrib/mergeEditor/browser/utils';
|
|
12
|
+
import { handledConflictMinimapOverViewRulerColor, unhandledConflictMinimapOverViewRulerColor } from '../colors.js';
|
|
13
|
+
import { EditorGutter } from '../editorGutter.js';
|
|
14
|
+
import { CodeEditorView, createSelectionsAutorun, TitleMenu } from './codeEditorView.js';
|
|
15
|
+
|
|
16
|
+
let BaseCodeEditorView = class BaseCodeEditorView extends CodeEditorView {
|
|
17
|
+
constructor(viewModel, instantiationService, configurationService) {
|
|
18
|
+
super(instantiationService, viewModel, configurationService);
|
|
19
|
+
this.decorations = derived(this, reader => {
|
|
20
|
+
const viewModel = this.viewModel.read(reader);
|
|
21
|
+
if (!viewModel) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const model = viewModel.model;
|
|
25
|
+
const textModel = model.base;
|
|
26
|
+
const activeModifiedBaseRange = viewModel.activeModifiedBaseRange.read(reader);
|
|
27
|
+
const showNonConflictingChanges = viewModel.showNonConflictingChanges.read(reader);
|
|
28
|
+
const showDeletionMarkers = this.showDeletionMarkers.read(reader);
|
|
29
|
+
const result = [];
|
|
30
|
+
for (const modifiedBaseRange of model.modifiedBaseRanges.read(reader)) {
|
|
31
|
+
const range = modifiedBaseRange.baseRange;
|
|
32
|
+
if (!range) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const isHandled = model.isHandled(modifiedBaseRange).read(reader);
|
|
36
|
+
if (!modifiedBaseRange.isConflicting && isHandled && !showNonConflictingChanges) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const blockClassNames = ['merge-editor-block'];
|
|
40
|
+
let blockPadding = [0, 0, 0, 0];
|
|
41
|
+
if (isHandled) {
|
|
42
|
+
blockClassNames.push('handled');
|
|
43
|
+
}
|
|
44
|
+
if (modifiedBaseRange === activeModifiedBaseRange) {
|
|
45
|
+
blockClassNames.push('focused');
|
|
46
|
+
blockPadding = [0, 2, 0, 2];
|
|
47
|
+
}
|
|
48
|
+
blockClassNames.push('base');
|
|
49
|
+
const inputToDiffAgainst = viewModel.baseShowDiffAgainst.read(reader);
|
|
50
|
+
if (inputToDiffAgainst) {
|
|
51
|
+
for (const diff of modifiedBaseRange.getInputDiffs(inputToDiffAgainst)) {
|
|
52
|
+
const range = diff.inputRange.toInclusiveRange();
|
|
53
|
+
if (range) {
|
|
54
|
+
result.push({
|
|
55
|
+
range,
|
|
56
|
+
options: {
|
|
57
|
+
className: `merge-editor-diff base`,
|
|
58
|
+
description: 'Merge Editor',
|
|
59
|
+
isWholeLine: true,
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
for (const diff2 of diff.rangeMappings) {
|
|
64
|
+
if (showDeletionMarkers || !diff2.inputRange.isEmpty()) {
|
|
65
|
+
result.push({
|
|
66
|
+
range: diff2.inputRange,
|
|
67
|
+
options: {
|
|
68
|
+
className: diff2.inputRange.isEmpty() ? `merge-editor-diff-empty-word base` : `merge-editor-diff-word base`,
|
|
69
|
+
description: 'Merge Editor',
|
|
70
|
+
showIfCollapsed: true,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
result.push({
|
|
78
|
+
range: range.toInclusiveRangeOrEmpty(),
|
|
79
|
+
options: {
|
|
80
|
+
showIfCollapsed: true,
|
|
81
|
+
blockClassName: blockClassNames.join(' '),
|
|
82
|
+
blockPadding,
|
|
83
|
+
blockIsAfterEnd: range.startLineNumber > textModel.getLineCount(),
|
|
84
|
+
description: 'Merge Editor',
|
|
85
|
+
minimap: {
|
|
86
|
+
position: MinimapPosition.Gutter,
|
|
87
|
+
color: { id: isHandled ? handledConflictMinimapOverViewRulerColor : unhandledConflictMinimapOverViewRulerColor },
|
|
88
|
+
},
|
|
89
|
+
overviewRuler: modifiedBaseRange.isConflicting ? {
|
|
90
|
+
position: OverviewRulerLane.Center,
|
|
91
|
+
color: { id: isHandled ? handledConflictMinimapOverViewRulerColor : unhandledConflictMinimapOverViewRulerColor },
|
|
92
|
+
} : undefined
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
});
|
|
98
|
+
this._register(createSelectionsAutorun(this, (baseRange, viewModel) => baseRange));
|
|
99
|
+
this._register(instantiationService.createInstance(TitleMenu, MenuId.MergeBaseToolbar, this.htmlElements.title));
|
|
100
|
+
this._register(autorunWithStore((reader, store) => {
|
|
101
|
+
if (this.checkboxesVisible.read(reader)) {
|
|
102
|
+
store.add(( new EditorGutter(this.editor, this.htmlElements.gutterDiv, {
|
|
103
|
+
getIntersectingGutterItems: (range, reader) => [],
|
|
104
|
+
createView: (item, target) => { throw new BugIndicatingError(); },
|
|
105
|
+
})));
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
this._register(autorun(reader => {
|
|
109
|
+
const vm = this.viewModel.read(reader);
|
|
110
|
+
if (!vm) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.editor.setModel(vm.model.base);
|
|
114
|
+
reset(this.htmlElements.title, ...renderLabelWithIcons(( localizeWithPath(
|
|
115
|
+
'vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView',
|
|
116
|
+
'base',
|
|
117
|
+
'Base'
|
|
118
|
+
))));
|
|
119
|
+
const baseShowDiffAgainst = vm.baseShowDiffAgainst.read(reader);
|
|
120
|
+
let node = undefined;
|
|
121
|
+
if (baseShowDiffAgainst) {
|
|
122
|
+
const label = ( localizeWithPath(
|
|
123
|
+
'vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView',
|
|
124
|
+
'compareWith',
|
|
125
|
+
'Comparing with {0}',
|
|
126
|
+
baseShowDiffAgainst === 1 ? vm.model.input1.title : vm.model.input2.title
|
|
127
|
+
));
|
|
128
|
+
const tooltip = ( localizeWithPath(
|
|
129
|
+
'vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView',
|
|
130
|
+
'compareWithTooltip',
|
|
131
|
+
'Differences are highlighted with a background color.'
|
|
132
|
+
));
|
|
133
|
+
node = h('span', { title: tooltip }, [label]).root;
|
|
134
|
+
}
|
|
135
|
+
reset(this.htmlElements.description, ...(node ? [node] : []));
|
|
136
|
+
}));
|
|
137
|
+
this._register(applyObservableDecorations(this.editor, this.decorations));
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
BaseCodeEditorView = ( __decorate([
|
|
141
|
+
( __param(1, IInstantiationService)),
|
|
142
|
+
( __param(2, IConfigurationService))
|
|
143
|
+
], BaseCodeEditorView));
|
|
144
|
+
|
|
145
|
+
export { BaseCodeEditorView };
|