@codingame/monaco-vscode-210e86a9-a91b-5273-b05d-390c776dde1f-common 16.1.1 → 17.0.0
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/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +1 -4
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +1 -2
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +1 -2
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.d.ts +30 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +269 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +43 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.d.ts +0 -34
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +0 -109
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@codingame/monaco-vscode-210e86a9-a91b-5273-b05d-390c776dde1f-common",
|
3
|
-
"version": "
|
3
|
+
"version": "17.0.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - common package (chat, extensions, interactive, notebook, terminal, view-common)",
|
6
6
|
"keywords": [],
|
@@ -15,7 +15,7 @@
|
|
15
15
|
},
|
16
16
|
"type": "module",
|
17
17
|
"dependencies": {
|
18
|
-
"@codingame/monaco-vscode-api": "
|
18
|
+
"@codingame/monaco-vscode-api": "17.0.0"
|
19
19
|
},
|
20
20
|
"exports": {
|
21
21
|
".": {
|
@@ -29,10 +29,7 @@ class LineRange {
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
join(other) {
|
32
|
-
return (
|
33
|
-
Math.min(this.startLineNumber, other.startLineNumber),
|
34
|
-
Math.max(this.endLineNumberExclusive, other.endLineNumberExclusive) - this.startLineNumber
|
35
|
-
));
|
32
|
+
return LineRange.fromLineNumbers(Math.min(this.startLineNumber, other.startLineNumber), Math.max(this.endLineNumberExclusive, other.endLineNumberExclusive));
|
36
33
|
}
|
37
34
|
get endLineNumberExclusive() {
|
38
35
|
return this.startLineNumber + this.lineCount;
|
@@ -1,10 +1,9 @@
|
|
1
1
|
|
2
|
-
import { compareBy, numberComparator } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
2
|
+
import { compareBy, numberComparator, concatArrays } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
3
3
|
import { findLast } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arraysFind';
|
4
4
|
import { assertFn, checkAdjacentItems } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
5
5
|
import { BugIndicatingError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
6
6
|
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
7
|
-
import { concatArrays } from '../utils.js';
|
8
7
|
import { LineRangeEdit } from './editing.js';
|
9
8
|
import { LineRange } from './lineRange.js';
|
10
9
|
import { rangeIsBeforeOrTouching, rangeContainsPosition, lengthBetweenPositions, addLength } from './rangeUtils.js';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
import { equals, tieBreakComparators, compareBy, numberComparator } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
2
|
+
import { equals, concatArrays, tieBreakComparators, compareBy, numberComparator } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
3
3
|
import { BugIndicatingError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
4
4
|
import { splitLines } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
5
5
|
import { Constants } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uint';
|
@@ -7,7 +7,6 @@ import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/c
|
|
7
7
|
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
8
8
|
import { RangeEdit, LineRangeEdit } from './editing.js';
|
9
9
|
import { MappingAlignment, DetailedLineRangeMapping } from './mapping.js';
|
10
|
-
import { concatArrays } from '../utils.js';
|
11
10
|
|
12
11
|
class ModifiedBaseRange {
|
13
12
|
static fromDiffs(diffs1, diffs2, baseTextModel, input1TextModel, input2TextModel) {
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
2
|
+
import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
3
|
+
import { ICodeEditor, IViewZoneChangeAccessor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
|
4
|
+
import { ModifiedBaseRange } from "../model/modifiedBaseRange.js";
|
5
|
+
import { MergeEditorViewModel } from "@codingame/monaco-vscode-view-common-service-override/vscode/vs/workbench/contrib/mergeEditor/browser/view/viewModel";
|
6
|
+
export declare class ConflictActionsFactory extends Disposable {
|
7
|
+
private readonly _editor;
|
8
|
+
private readonly _styleClassName;
|
9
|
+
private readonly _styleElement;
|
10
|
+
constructor(_editor: ICodeEditor);
|
11
|
+
private _updateLensStyle;
|
12
|
+
private _getLayoutInfo;
|
13
|
+
createWidget(viewZoneChangeAccessor: IViewZoneChangeAccessor, lineNumber: number, items: IObservable<IContentWidgetAction[]>, viewZoneIdsToCleanUp: string[]): IDisposable;
|
14
|
+
}
|
15
|
+
export declare class ActionsSource {
|
16
|
+
private readonly viewModel;
|
17
|
+
private readonly modifiedBaseRange;
|
18
|
+
constructor(viewModel: MergeEditorViewModel, modifiedBaseRange: ModifiedBaseRange);
|
19
|
+
private getItemsInput;
|
20
|
+
readonly itemsInput1: IObservable<IContentWidgetAction[]>;
|
21
|
+
readonly itemsInput2: IObservable<IContentWidgetAction[]>;
|
22
|
+
readonly resultItems: IObservable<IContentWidgetAction[]>;
|
23
|
+
readonly isEmpty: IObservable<boolean>;
|
24
|
+
readonly inputIsEmpty: IObservable<boolean>;
|
25
|
+
}
|
26
|
+
export interface IContentWidgetAction {
|
27
|
+
text: string;
|
28
|
+
tooltip?: string;
|
29
|
+
action?: () => Promise<void>;
|
30
|
+
}
|
@@ -0,0 +1,269 @@
|
|
1
|
+
|
2
|
+
import { isInShadowDOM, h, $, reset } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
3
|
+
import { createStyleSheet } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
|
4
|
+
import { renderLabelWithIcons } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/iconLabel/iconLabels';
|
5
|
+
import { hash } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hash';
|
6
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
7
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
8
|
+
import { EditorOption, EDITOR_FONT_DEFAULTS } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
|
9
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
10
|
+
import { ModifiedBaseRangeStateKind, ModifiedBaseRangeState } from '../model/modifiedBaseRange.js';
|
11
|
+
import { FixedZoneWidget } from './fixedZoneWidget.js';
|
12
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
13
|
+
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
14
|
+
import { transaction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
15
|
+
|
16
|
+
class ConflictActionsFactory extends Disposable {
|
17
|
+
constructor(_editor) {
|
18
|
+
super();
|
19
|
+
this._editor = _editor;
|
20
|
+
this._register(this._editor.onDidChangeConfiguration((e) => {
|
21
|
+
if (e.hasChanged(EditorOption.fontInfo) || e.hasChanged(EditorOption.codeLensFontSize) || e.hasChanged(EditorOption.codeLensFontFamily)) {
|
22
|
+
this._updateLensStyle();
|
23
|
+
}
|
24
|
+
}));
|
25
|
+
this._styleClassName = '_conflictActionsFactory_' + ( hash(this._editor.getId()).toString(16));
|
26
|
+
this._styleElement = createStyleSheet(isInShadowDOM(this._editor.getContainerDomNode())
|
27
|
+
? this._editor.getContainerDomNode()
|
28
|
+
: undefined, undefined, this._store);
|
29
|
+
this._updateLensStyle();
|
30
|
+
}
|
31
|
+
_updateLensStyle() {
|
32
|
+
const { codeLensHeight, fontSize } = this._getLayoutInfo();
|
33
|
+
const fontFamily = this._editor.getOption(EditorOption.codeLensFontFamily);
|
34
|
+
const editorFontInfo = this._editor.getOption(EditorOption.fontInfo);
|
35
|
+
const fontFamilyVar = `--codelens-font-family${this._styleClassName}`;
|
36
|
+
const fontFeaturesVar = `--codelens-font-features${this._styleClassName}`;
|
37
|
+
let newStyle = `
|
38
|
+
.${this._styleClassName} { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; padding-right: ${Math.round(fontSize * 0.5)}px; font-feature-settings: var(${fontFeaturesVar}) }
|
39
|
+
.monaco-workbench .${this._styleClassName} span.codicon { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; }
|
40
|
+
`;
|
41
|
+
if (fontFamily) {
|
42
|
+
newStyle += `${this._styleClassName} { font-family: var(${fontFamilyVar}), ${EDITOR_FONT_DEFAULTS.fontFamily}}`;
|
43
|
+
}
|
44
|
+
this._styleElement.textContent = newStyle;
|
45
|
+
this._editor.getContainerDomNode().style?.setProperty(fontFamilyVar, fontFamily ?? 'inherit');
|
46
|
+
this._editor.getContainerDomNode().style?.setProperty(fontFeaturesVar, editorFontInfo.fontFeatureSettings);
|
47
|
+
}
|
48
|
+
_getLayoutInfo() {
|
49
|
+
const lineHeightFactor = Math.max(1.3, this._editor.getOption(EditorOption.lineHeight) / this._editor.getOption(EditorOption.fontSize));
|
50
|
+
let fontSize = this._editor.getOption(EditorOption.codeLensFontSize);
|
51
|
+
if (!fontSize || fontSize < 5) {
|
52
|
+
fontSize = (this._editor.getOption(EditorOption.fontSize) * .9) | 0;
|
53
|
+
}
|
54
|
+
return {
|
55
|
+
fontSize,
|
56
|
+
codeLensHeight: (fontSize * lineHeightFactor) | 0,
|
57
|
+
};
|
58
|
+
}
|
59
|
+
createWidget(viewZoneChangeAccessor, lineNumber, items, viewZoneIdsToCleanUp) {
|
60
|
+
const layoutInfo = this._getLayoutInfo();
|
61
|
+
return ( new ActionsContentWidget(
|
62
|
+
this._editor,
|
63
|
+
viewZoneChangeAccessor,
|
64
|
+
lineNumber,
|
65
|
+
layoutInfo.codeLensHeight + 2,
|
66
|
+
this._styleClassName,
|
67
|
+
items,
|
68
|
+
viewZoneIdsToCleanUp
|
69
|
+
));
|
70
|
+
}
|
71
|
+
}
|
72
|
+
class ActionsSource {
|
73
|
+
constructor(viewModel, modifiedBaseRange) {
|
74
|
+
this.viewModel = viewModel;
|
75
|
+
this.modifiedBaseRange = modifiedBaseRange;
|
76
|
+
this.itemsInput1 = this.getItemsInput(1);
|
77
|
+
this.itemsInput2 = this.getItemsInput(2);
|
78
|
+
this.resultItems = derived(this, reader => {
|
79
|
+
const viewModel = this.viewModel;
|
80
|
+
const modifiedBaseRange = this.modifiedBaseRange;
|
81
|
+
const state = viewModel.model.getState(modifiedBaseRange).read(reader);
|
82
|
+
const model = viewModel.model;
|
83
|
+
const result = [];
|
84
|
+
if (state.kind === ModifiedBaseRangeStateKind.unrecognized) {
|
85
|
+
result.push({
|
86
|
+
text: ( localize(7856, "Manual Resolution")),
|
87
|
+
tooltip: ( localize(7857, "This conflict has been resolved manually.")),
|
88
|
+
});
|
89
|
+
}
|
90
|
+
else if (state.kind === ModifiedBaseRangeStateKind.base) {
|
91
|
+
result.push({
|
92
|
+
text: ( localize(7858, 'No Changes Accepted')),
|
93
|
+
tooltip: ( localize(
|
94
|
+
7859,
|
95
|
+
'The current resolution of this conflict equals the common ancestor of both the right and left changes.'
|
96
|
+
)),
|
97
|
+
});
|
98
|
+
}
|
99
|
+
else {
|
100
|
+
const labels = [];
|
101
|
+
if (state.includesInput1) {
|
102
|
+
labels.push(model.input1.title);
|
103
|
+
}
|
104
|
+
if (state.includesInput2) {
|
105
|
+
labels.push(model.input2.title);
|
106
|
+
}
|
107
|
+
if (state.kind === ModifiedBaseRangeStateKind.both && state.firstInput === 2) {
|
108
|
+
labels.reverse();
|
109
|
+
}
|
110
|
+
result.push({
|
111
|
+
text: `${labels.join(' + ')}`
|
112
|
+
});
|
113
|
+
}
|
114
|
+
const stateToggles = [];
|
115
|
+
if (state.includesInput1) {
|
116
|
+
stateToggles.push(command(( localize(7860, 'Remove {0}', model.input1.title)), async () => {
|
117
|
+
transaction((tx) => {
|
118
|
+
model.setState(modifiedBaseRange, state.withInputValue(1, false), true, tx);
|
119
|
+
model.telemetry.reportRemoveInvoked(1, state.includesInput(2));
|
120
|
+
});
|
121
|
+
}, ( localize(7861, 'Remove {0} from the result document.', model.input1.title))));
|
122
|
+
}
|
123
|
+
if (state.includesInput2) {
|
124
|
+
stateToggles.push(command(( localize(7860, 'Remove {0}', model.input2.title)), async () => {
|
125
|
+
transaction((tx) => {
|
126
|
+
model.setState(modifiedBaseRange, state.withInputValue(2, false), true, tx);
|
127
|
+
model.telemetry.reportRemoveInvoked(2, state.includesInput(1));
|
128
|
+
});
|
129
|
+
}, ( localize(7861, 'Remove {0} from the result document.', model.input2.title))));
|
130
|
+
}
|
131
|
+
if (state.kind === ModifiedBaseRangeStateKind.both &&
|
132
|
+
state.firstInput === 2) {
|
133
|
+
stateToggles.reverse();
|
134
|
+
}
|
135
|
+
result.push(...stateToggles);
|
136
|
+
if (state.kind === ModifiedBaseRangeStateKind.unrecognized) {
|
137
|
+
result.push(command(( localize(7862, 'Reset to base')), async () => {
|
138
|
+
transaction((tx) => {
|
139
|
+
model.setState(modifiedBaseRange, ModifiedBaseRangeState.base, true, tx);
|
140
|
+
model.telemetry.reportResetToBaseInvoked();
|
141
|
+
});
|
142
|
+
}, ( localize(
|
143
|
+
7863,
|
144
|
+
'Reset this conflict to the common ancestor of both the right and left changes.'
|
145
|
+
))));
|
146
|
+
}
|
147
|
+
return result;
|
148
|
+
});
|
149
|
+
this.isEmpty = derived(this, reader => {
|
150
|
+
return this.itemsInput1.read(reader).length + this.itemsInput2.read(reader).length + this.resultItems.read(reader).length === 0;
|
151
|
+
});
|
152
|
+
this.inputIsEmpty = derived(this, reader => {
|
153
|
+
return this.itemsInput1.read(reader).length + this.itemsInput2.read(reader).length === 0;
|
154
|
+
});
|
155
|
+
}
|
156
|
+
getItemsInput(inputNumber) {
|
157
|
+
return derived(reader => {
|
158
|
+
const viewModel = this.viewModel;
|
159
|
+
const modifiedBaseRange = this.modifiedBaseRange;
|
160
|
+
if (!viewModel.model.hasBaseRange(modifiedBaseRange)) {
|
161
|
+
return [];
|
162
|
+
}
|
163
|
+
const state = viewModel.model.getState(modifiedBaseRange).read(reader);
|
164
|
+
const handled = viewModel.model.isHandled(modifiedBaseRange).read(reader);
|
165
|
+
const model = viewModel.model;
|
166
|
+
const result = [];
|
167
|
+
const inputData = inputNumber === 1 ? viewModel.model.input1 : viewModel.model.input2;
|
168
|
+
const showNonConflictingChanges = viewModel.showNonConflictingChanges.read(reader);
|
169
|
+
if (!modifiedBaseRange.isConflicting && handled && !showNonConflictingChanges) {
|
170
|
+
return [];
|
171
|
+
}
|
172
|
+
const otherInputNumber = inputNumber === 1 ? 2 : 1;
|
173
|
+
if (state.kind !== ModifiedBaseRangeStateKind.unrecognized && !state.isInputIncluded(inputNumber)) {
|
174
|
+
if (!state.isInputIncluded(otherInputNumber) || !this.viewModel.shouldUseAppendInsteadOfAccept.read(reader)) {
|
175
|
+
result.push(command(( localize(7864, "Accept {0}", inputData.title)), async () => {
|
176
|
+
transaction((tx) => {
|
177
|
+
model.setState(modifiedBaseRange, state.withInputValue(inputNumber, true, false), inputNumber, tx);
|
178
|
+
model.telemetry.reportAcceptInvoked(inputNumber, state.includesInput(otherInputNumber));
|
179
|
+
});
|
180
|
+
}, ( localize(7865, "Accept {0} in the result document.", inputData.title))));
|
181
|
+
if (modifiedBaseRange.canBeCombined) {
|
182
|
+
const commandName = modifiedBaseRange.isOrderRelevant
|
183
|
+
? ( localize(7866, "Accept Combination ({0} First)", inputData.title))
|
184
|
+
: ( localize(7867, "Accept Combination"));
|
185
|
+
result.push(command(commandName, async () => {
|
186
|
+
transaction((tx) => {
|
187
|
+
model.setState(modifiedBaseRange, ModifiedBaseRangeState.base
|
188
|
+
.withInputValue(inputNumber, true)
|
189
|
+
.withInputValue(otherInputNumber, true, true), true, tx);
|
190
|
+
model.telemetry.reportSmartCombinationInvoked(state.includesInput(otherInputNumber));
|
191
|
+
});
|
192
|
+
}, ( localize(
|
193
|
+
7868,
|
194
|
+
"Accept an automatic combination of both sides in the result document."
|
195
|
+
))));
|
196
|
+
}
|
197
|
+
}
|
198
|
+
else {
|
199
|
+
result.push(command(( localize(7869, "Append {0}", inputData.title)), async () => {
|
200
|
+
transaction((tx) => {
|
201
|
+
model.setState(modifiedBaseRange, state.withInputValue(inputNumber, true, false), inputNumber, tx);
|
202
|
+
model.telemetry.reportAcceptInvoked(inputNumber, state.includesInput(otherInputNumber));
|
203
|
+
});
|
204
|
+
}, ( localize(7870, "Append {0} to the result document.", inputData.title))));
|
205
|
+
if (modifiedBaseRange.canBeCombined) {
|
206
|
+
result.push(command(( localize(7871, "Accept Combination", inputData.title)), async () => {
|
207
|
+
transaction((tx) => {
|
208
|
+
model.setState(modifiedBaseRange, state.withInputValue(inputNumber, true, true), inputNumber, tx);
|
209
|
+
model.telemetry.reportSmartCombinationInvoked(state.includesInput(otherInputNumber));
|
210
|
+
});
|
211
|
+
}, ( localize(
|
212
|
+
7868,
|
213
|
+
"Accept an automatic combination of both sides in the result document."
|
214
|
+
))));
|
215
|
+
}
|
216
|
+
}
|
217
|
+
if (!model.isInputHandled(modifiedBaseRange, inputNumber).read(reader)) {
|
218
|
+
result.push(command(( localize(7872, 'Ignore')), async () => {
|
219
|
+
transaction((tx) => {
|
220
|
+
model.setInputHandled(modifiedBaseRange, inputNumber, true, tx);
|
221
|
+
});
|
222
|
+
}, ( localize(7873, "Don't take this side of the conflict."))));
|
223
|
+
}
|
224
|
+
}
|
225
|
+
return result;
|
226
|
+
});
|
227
|
+
}
|
228
|
+
}
|
229
|
+
function command(title, action, tooltip) {
|
230
|
+
return {
|
231
|
+
text: title,
|
232
|
+
action,
|
233
|
+
tooltip,
|
234
|
+
};
|
235
|
+
}
|
236
|
+
class ActionsContentWidget extends FixedZoneWidget {
|
237
|
+
constructor(editor, viewZoneAccessor, afterLineNumber, height, className, items, viewZoneIdsToCleanUp) {
|
238
|
+
super(editor, viewZoneAccessor, afterLineNumber, height, viewZoneIdsToCleanUp);
|
239
|
+
this._domNode = h('div.merge-editor-conflict-actions').root;
|
240
|
+
this.widgetDomNode.appendChild(this._domNode);
|
241
|
+
this._domNode.classList.add(className);
|
242
|
+
this._register(autorun(reader => {
|
243
|
+
const i = items.read(reader);
|
244
|
+
this.setState(i);
|
245
|
+
}));
|
246
|
+
}
|
247
|
+
setState(items) {
|
248
|
+
const children = [];
|
249
|
+
let isFirst = true;
|
250
|
+
for (const item of items) {
|
251
|
+
if (isFirst) {
|
252
|
+
isFirst = false;
|
253
|
+
}
|
254
|
+
else {
|
255
|
+
children.push($('span', undefined, '\u00a0|\u00a0'));
|
256
|
+
}
|
257
|
+
const title = renderLabelWithIcons(item.text);
|
258
|
+
if (item.action) {
|
259
|
+
children.push($('a', { title: item.tooltip, role: 'button', onclick: () => item.action() }, ...title));
|
260
|
+
}
|
261
|
+
else {
|
262
|
+
children.push($('span', { title: item.tooltip }, ...title));
|
263
|
+
}
|
264
|
+
}
|
265
|
+
reset(this._domNode, ...children);
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
export { ActionsSource, ConflictActionsFactory };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
2
|
+
import { ICodeEditor, IViewZoneChangeAccessor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
|
3
|
+
export declare abstract class FixedZoneWidget extends Disposable {
|
4
|
+
private readonly editor;
|
5
|
+
private static counter;
|
6
|
+
private readonly overlayWidgetId;
|
7
|
+
private readonly viewZoneId;
|
8
|
+
protected readonly widgetDomNode: HTMLDivElement;
|
9
|
+
private readonly overlayWidget;
|
10
|
+
constructor(editor: ICodeEditor, viewZoneAccessor: IViewZoneChangeAccessor, afterLineNumber: number, height: number, viewZoneIdsToCleanUp: string[]);
|
11
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
import { h } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
3
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
4
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
5
|
+
|
6
|
+
class FixedZoneWidget extends Disposable {
|
7
|
+
static { this.counter = 0; }
|
8
|
+
constructor(editor, viewZoneAccessor, afterLineNumber, height, viewZoneIdsToCleanUp) {
|
9
|
+
super();
|
10
|
+
this.editor = editor;
|
11
|
+
this.overlayWidgetId = `fixedZoneWidget-${FixedZoneWidget.counter++}`;
|
12
|
+
this.widgetDomNode = h('div.fixed-zone-widget').root;
|
13
|
+
this.overlayWidget = {
|
14
|
+
getId: () => this.overlayWidgetId,
|
15
|
+
getDomNode: () => this.widgetDomNode,
|
16
|
+
getPosition: () => null
|
17
|
+
};
|
18
|
+
this.viewZoneId = viewZoneAccessor.addZone({
|
19
|
+
domNode: document.createElement('div'),
|
20
|
+
afterLineNumber: afterLineNumber,
|
21
|
+
heightInPx: height,
|
22
|
+
ordinal: 50000 + 1,
|
23
|
+
onComputedHeight: (height) => {
|
24
|
+
this.widgetDomNode.style.height = `${height}px`;
|
25
|
+
},
|
26
|
+
onDomNodeTop: (top) => {
|
27
|
+
this.widgetDomNode.style.top = `${top}px`;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
viewZoneIdsToCleanUp.push(this.viewZoneId);
|
31
|
+
this._register(Event.runAndSubscribe(this.editor.onDidLayoutChange, () => {
|
32
|
+
this.widgetDomNode.style.left = this.editor.getLayoutInfo().contentLeft + 'px';
|
33
|
+
}));
|
34
|
+
this.editor.addOverlayWidget(this.overlayWidget);
|
35
|
+
this._register({
|
36
|
+
dispose: () => {
|
37
|
+
this.editor.removeOverlayWidget(this.overlayWidget);
|
38
|
+
},
|
39
|
+
});
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
export { FixedZoneWidget };
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { CompareResult } from "@codingame/monaco-vscode-api/vscode/vs/base/common/arrays";
|
2
|
-
import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
3
|
-
import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
4
|
-
import { CodeEditorWidget } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget";
|
5
|
-
import { IModelDeltaDecoration } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
6
|
-
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
7
|
-
export declare function setStyle(element: HTMLElement, style: {
|
8
|
-
width?: number | string;
|
9
|
-
height?: number | string;
|
10
|
-
left?: number | string;
|
11
|
-
top?: number | string;
|
12
|
-
}): void;
|
13
|
-
export declare function applyObservableDecorations(editor: CodeEditorWidget, decorations: IObservable<IModelDeltaDecoration[]>): IDisposable;
|
14
|
-
export declare function leftJoin<TLeft, TRight>(left: Iterable<TLeft>, right: readonly TRight[], compare: (left: TLeft, right: TRight) => CompareResult): IterableIterator<{
|
15
|
-
left: TLeft;
|
16
|
-
rights: TRight[];
|
17
|
-
}>;
|
18
|
-
export declare function join<TLeft, TRight>(left: Iterable<TLeft>, right: readonly TRight[], compare: (left: TLeft, right: TRight) => CompareResult): IterableIterator<{
|
19
|
-
left?: TLeft;
|
20
|
-
rights: TRight[];
|
21
|
-
}>;
|
22
|
-
export declare function concatArrays<TArr extends any[]>(...arrays: TArr): TArr[number][number][];
|
23
|
-
export declare function elementAtOrUndefined<T>(arr: T[], index: number): T | undefined;
|
24
|
-
export declare function setFields<T extends {}>(obj: T, fields: Partial<T>): T;
|
25
|
-
export declare function deepMerge<T extends {}>(source1: T, source2: Partial<T>): T;
|
26
|
-
export declare class PersistentStore<T> {
|
27
|
-
private readonly key;
|
28
|
-
private readonly storageService;
|
29
|
-
private hasValue;
|
30
|
-
private value;
|
31
|
-
constructor(key: string, storageService: IStorageService);
|
32
|
-
get(): Readonly<T> | undefined;
|
33
|
-
set(newValue: T | undefined): void;
|
34
|
-
}
|
@@ -1,109 +0,0 @@
|
|
1
|
-
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
3
|
-
import { ArrayQueue, CompareResult } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
4
|
-
import { onUnexpectedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
5
|
-
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
6
|
-
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
7
|
-
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
8
|
-
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
9
|
-
import { autorunOpts } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
10
|
-
|
11
|
-
function setStyle(element, style) {
|
12
|
-
Object.entries(style).forEach(([key, value]) => {
|
13
|
-
element.style.setProperty(key, toSize(value));
|
14
|
-
});
|
15
|
-
}
|
16
|
-
function toSize(value) {
|
17
|
-
return typeof value === 'number' ? `${value}px` : value;
|
18
|
-
}
|
19
|
-
function applyObservableDecorations(editor, decorations) {
|
20
|
-
const d = ( new DisposableStore());
|
21
|
-
let decorationIds = [];
|
22
|
-
d.add(autorunOpts({ debugName: () => `Apply decorations from ${decorations.debugName}` }, reader => {
|
23
|
-
const d = decorations.read(reader);
|
24
|
-
editor.changeDecorations(a => {
|
25
|
-
decorationIds = a.deltaDecorations(decorationIds, d);
|
26
|
-
});
|
27
|
-
}));
|
28
|
-
d.add({
|
29
|
-
dispose: () => {
|
30
|
-
editor.changeDecorations(a => {
|
31
|
-
decorationIds = a.deltaDecorations(decorationIds, []);
|
32
|
-
});
|
33
|
-
}
|
34
|
-
});
|
35
|
-
return d;
|
36
|
-
}
|
37
|
-
function* leftJoin(left, right, compare) {
|
38
|
-
const rightQueue = ( new ArrayQueue(right));
|
39
|
-
for (const leftElement of left) {
|
40
|
-
rightQueue.takeWhile(rightElement => CompareResult.isGreaterThan(compare(leftElement, rightElement)));
|
41
|
-
const equals = rightQueue.takeWhile(rightElement => CompareResult.isNeitherLessOrGreaterThan(compare(leftElement, rightElement)));
|
42
|
-
yield { left: leftElement, rights: equals || [] };
|
43
|
-
}
|
44
|
-
}
|
45
|
-
function* join(left, right, compare) {
|
46
|
-
const rightQueue = ( new ArrayQueue(right));
|
47
|
-
for (const leftElement of left) {
|
48
|
-
const skipped = rightQueue.takeWhile(rightElement => CompareResult.isGreaterThan(compare(leftElement, rightElement)));
|
49
|
-
if (skipped) {
|
50
|
-
yield { rights: skipped };
|
51
|
-
}
|
52
|
-
const equals = rightQueue.takeWhile(rightElement => CompareResult.isNeitherLessOrGreaterThan(compare(leftElement, rightElement)));
|
53
|
-
yield { left: leftElement, rights: equals || [] };
|
54
|
-
}
|
55
|
-
}
|
56
|
-
function concatArrays(...arrays) {
|
57
|
-
return [].concat(...arrays);
|
58
|
-
}
|
59
|
-
function setFields(obj, fields) {
|
60
|
-
return Object.assign(obj, fields);
|
61
|
-
}
|
62
|
-
function deepMerge(source1, source2) {
|
63
|
-
const result = {};
|
64
|
-
for (const key in source1) {
|
65
|
-
result[key] = source1[key];
|
66
|
-
}
|
67
|
-
for (const key in source2) {
|
68
|
-
const source2Value = source2[key];
|
69
|
-
if (typeof result[key] === 'object' && source2Value && typeof source2Value === 'object') {
|
70
|
-
result[key] = deepMerge(result[key], source2Value);
|
71
|
-
}
|
72
|
-
else {
|
73
|
-
result[key] = source2Value;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
return result;
|
77
|
-
}
|
78
|
-
let PersistentStore = class PersistentStore {
|
79
|
-
constructor(key, storageService) {
|
80
|
-
this.key = key;
|
81
|
-
this.storageService = storageService;
|
82
|
-
this.hasValue = false;
|
83
|
-
this.value = undefined;
|
84
|
-
}
|
85
|
-
get() {
|
86
|
-
if (!this.hasValue) {
|
87
|
-
const value = this.storageService.get(this.key, StorageScope.PROFILE);
|
88
|
-
if (value !== undefined) {
|
89
|
-
try {
|
90
|
-
this.value = JSON.parse(value);
|
91
|
-
}
|
92
|
-
catch (e) {
|
93
|
-
onUnexpectedError(e);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
this.hasValue = true;
|
97
|
-
}
|
98
|
-
return this.value;
|
99
|
-
}
|
100
|
-
set(newValue) {
|
101
|
-
this.value = newValue;
|
102
|
-
this.storageService.store(this.key, JSON.stringify(this.value), StorageScope.PROFILE, StorageTarget.USER);
|
103
|
-
}
|
104
|
-
};
|
105
|
-
PersistentStore = ( __decorate([
|
106
|
-
( __param(1, IStorageService))
|
107
|
-
], PersistentStore));
|
108
|
-
|
109
|
-
export { PersistentStore, applyObservableDecorations, concatArrays, deepMerge, join, leftJoin, setFields, setStyle };
|