@codingame/monaco-vscode-extensions-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/extensions.js +3 -3
- package/package.json +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +1 -1
- package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +1 -1
- package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +8 -8
- package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +1 -1
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +2 -2
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +3 -3
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +2 -2
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +1 -1
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +0 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +0 -141
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +0 -37
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +0 -342
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +0 -1197
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +0 -117
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +0 -83
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +0 -543
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +0 -292
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +0 -169
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +0 -255
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +0 -195
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +0 -260
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +0 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +0 -26
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +0 -63
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +0 -51
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +0 -649
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +0 -302
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +0 -62
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +0 -251
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +0 -109
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +0 -335
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +0 -101
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +0 -57
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +0 -3
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +0 -144
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +0 -482
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +0 -6
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +0 -92
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +0 -56
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +0 -110
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +0 -260
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +0 -616
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +0 -309
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +0 -38
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +0 -167
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +0 -80
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +0 -70
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +0 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +0 -108
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +0 -506
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.js +0 -132
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +0 -79
|
@@ -1,616 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { equals, CompareResult } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
3
|
-
import { BugIndicatingError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
4
|
-
import { derived, waitForState, keepObserved, autorunHandleChanges, transaction, observableValue } from 'monaco-editor/esm/vs/base/common/observable.js';
|
|
5
|
-
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
6
|
-
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
7
|
-
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
-
import { IUndoRedoService, UndoRedoGroup } from 'monaco-editor/esm/vs/platform/undoRedo/common/undoRedo.js';
|
|
9
|
-
import { EditorModel } from 'vscode/vscode/vs/workbench/common/editor/editorModel';
|
|
10
|
-
import { LineRange } from './lineRange.js';
|
|
11
|
-
import { DocumentLineRangeMap, LineRangeMapping, DocumentRangeMap } from './mapping.js';
|
|
12
|
-
import { TextModelDiffs } from './textModelDiffs.js';
|
|
13
|
-
import { leftJoin } from '../utils.js';
|
|
14
|
-
import { ModifiedBaseRange, ModifiedBaseRangeStateKind, ModifiedBaseRangeState } from './modifiedBaseRange.js';
|
|
15
|
-
|
|
16
|
-
let MergeEditorModel = class MergeEditorModel extends EditorModel {
|
|
17
|
-
constructor(base, input1, input2, resultTextModel, diffComputer, options, telemetry, languageService, undoRedoService) {
|
|
18
|
-
super();
|
|
19
|
-
this.base = base;
|
|
20
|
-
this.input1 = input1;
|
|
21
|
-
this.input2 = input2;
|
|
22
|
-
this.resultTextModel = resultTextModel;
|
|
23
|
-
this.diffComputer = diffComputer;
|
|
24
|
-
this.options = options;
|
|
25
|
-
this.telemetry = telemetry;
|
|
26
|
-
this.languageService = languageService;
|
|
27
|
-
this.undoRedoService = undoRedoService;
|
|
28
|
-
this.input1TextModelDiffs = this._register(( new TextModelDiffs(this.base, this.input1.textModel, this.diffComputer)));
|
|
29
|
-
this.input2TextModelDiffs = this._register(( new TextModelDiffs(this.base, this.input2.textModel, this.diffComputer)));
|
|
30
|
-
this.resultTextModelDiffs = this._register(( new TextModelDiffs(this.base, this.resultTextModel, this.diffComputer)));
|
|
31
|
-
this.modifiedBaseRanges = derived(this, (reader) => {
|
|
32
|
-
const input1Diffs = this.input1TextModelDiffs.diffs.read(reader);
|
|
33
|
-
const input2Diffs = this.input2TextModelDiffs.diffs.read(reader);
|
|
34
|
-
return ModifiedBaseRange.fromDiffs(input1Diffs, input2Diffs, this.base, this.input1.textModel, this.input2.textModel);
|
|
35
|
-
});
|
|
36
|
-
this.modifiedBaseRangeResultStates = derived(this, reader => {
|
|
37
|
-
const map = ( new Map(( this.modifiedBaseRanges.read(reader).map((s) => [
|
|
38
|
-
s, ( new ModifiedBaseRangeData(s))
|
|
39
|
-
]))));
|
|
40
|
-
return map;
|
|
41
|
-
});
|
|
42
|
-
this.resultSnapshot = this.resultTextModel.createSnapshot();
|
|
43
|
-
this.baseInput1Diffs = this.input1TextModelDiffs.diffs;
|
|
44
|
-
this.baseInput2Diffs = this.input2TextModelDiffs.diffs;
|
|
45
|
-
this.baseResultDiffs = this.resultTextModelDiffs.diffs;
|
|
46
|
-
this.input1ResultMapping = derived(this, reader => {
|
|
47
|
-
return this.getInputResultMapping(this.baseInput1Diffs.read(reader), this.baseResultDiffs.read(reader), this.input1.textModel.getLineCount());
|
|
48
|
-
});
|
|
49
|
-
this.resultInput1Mapping = derived(this, reader => this.input1ResultMapping.read(reader).reverse());
|
|
50
|
-
this.input2ResultMapping = derived(this, reader => {
|
|
51
|
-
return this.getInputResultMapping(this.baseInput2Diffs.read(reader), this.baseResultDiffs.read(reader), this.input2.textModel.getLineCount());
|
|
52
|
-
});
|
|
53
|
-
this.resultInput2Mapping = derived(this, reader => this.input2ResultMapping.read(reader).reverse());
|
|
54
|
-
this.baseResultMapping = derived(this, reader => {
|
|
55
|
-
const map = ( new DocumentLineRangeMap(this.baseResultDiffs.read(reader), -1));
|
|
56
|
-
return ( new DocumentLineRangeMap(( map.lineRangeMappings.map((m) => m.inputRange.isEmpty || m.outputRange.isEmpty
|
|
57
|
-
? ( new LineRangeMapping(
|
|
58
|
-
m.inputRange.deltaStart(-1), m.outputRange.deltaStart(-1)))
|
|
59
|
-
: m)), map.inputLineCount));
|
|
60
|
-
});
|
|
61
|
-
this.resultBaseMapping = derived(this, reader => this.baseResultMapping.read(reader).reverse());
|
|
62
|
-
this.diffComputingState = derived(this, reader => {
|
|
63
|
-
const states = ( [
|
|
64
|
-
this.input1TextModelDiffs,
|
|
65
|
-
this.input2TextModelDiffs,
|
|
66
|
-
this.resultTextModelDiffs,
|
|
67
|
-
].map((s) => s.state.read(reader)));
|
|
68
|
-
if (( states.some((s) => s === 1 ))) {
|
|
69
|
-
return 1 ;
|
|
70
|
-
}
|
|
71
|
-
if (( states.some((s) => s === 3 ))) {
|
|
72
|
-
return 3 ;
|
|
73
|
-
}
|
|
74
|
-
return 2 ;
|
|
75
|
-
});
|
|
76
|
-
this.inputDiffComputingState = derived(this, reader => {
|
|
77
|
-
const states = ( [
|
|
78
|
-
this.input1TextModelDiffs,
|
|
79
|
-
this.input2TextModelDiffs,
|
|
80
|
-
].map((s) => s.state.read(reader)));
|
|
81
|
-
if (( states.some((s) => s === 1 ))) {
|
|
82
|
-
return 1 ;
|
|
83
|
-
}
|
|
84
|
-
if (( states.some((s) => s === 3 ))) {
|
|
85
|
-
return 3 ;
|
|
86
|
-
}
|
|
87
|
-
return 2 ;
|
|
88
|
-
});
|
|
89
|
-
this.isUpToDate = derived(this, reader => this.diffComputingState.read(reader) === 2 );
|
|
90
|
-
this.onInitialized = waitForState(this.diffComputingState, state => state === 2 ).then(() => { });
|
|
91
|
-
this.firstRun = true;
|
|
92
|
-
this.unhandledConflictsCount = derived(this, reader => {
|
|
93
|
-
const map = this.modifiedBaseRangeResultStates.read(reader);
|
|
94
|
-
let unhandledCount = 0;
|
|
95
|
-
for (const [_key, value] of map) {
|
|
96
|
-
if (!value.handled.read(reader)) {
|
|
97
|
-
unhandledCount++;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return unhandledCount;
|
|
101
|
-
});
|
|
102
|
-
this.hasUnhandledConflicts = ( this.unhandledConflictsCount.map(value => value > 0));
|
|
103
|
-
this._register(keepObserved(this.modifiedBaseRangeResultStates));
|
|
104
|
-
this._register(keepObserved(this.input1ResultMapping));
|
|
105
|
-
this._register(keepObserved(this.input2ResultMapping));
|
|
106
|
-
const initializePromise = this.initialize();
|
|
107
|
-
this.onInitialized = this.onInitialized.then(async () => {
|
|
108
|
-
await initializePromise;
|
|
109
|
-
});
|
|
110
|
-
initializePromise.then(() => {
|
|
111
|
-
let shouldRecomputeHandledFromAccepted = true;
|
|
112
|
-
this._register(autorunHandleChanges({
|
|
113
|
-
handleChange: (ctx) => {
|
|
114
|
-
if (ctx.didChange(this.modifiedBaseRangeResultStates)) {
|
|
115
|
-
shouldRecomputeHandledFromAccepted = true;
|
|
116
|
-
}
|
|
117
|
-
return ctx.didChange(this.resultTextModelDiffs.diffs)
|
|
118
|
-
? ctx.change === 1
|
|
119
|
-
: true;
|
|
120
|
-
},
|
|
121
|
-
}, (reader) => {
|
|
122
|
-
const states = this.modifiedBaseRangeResultStates.read(reader);
|
|
123
|
-
if (!this.isUpToDate.read(reader)) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const resultDiffs = this.resultTextModelDiffs.diffs.read(reader);
|
|
127
|
-
transaction(tx => {
|
|
128
|
-
this.updateBaseRangeAcceptedState(resultDiffs, states, tx);
|
|
129
|
-
if (shouldRecomputeHandledFromAccepted) {
|
|
130
|
-
shouldRecomputeHandledFromAccepted = false;
|
|
131
|
-
for (const [_range, observableState] of states) {
|
|
132
|
-
const state = observableState.accepted.get();
|
|
133
|
-
const handled = !(state.kind === ModifiedBaseRangeStateKind.base || state.kind === ModifiedBaseRangeStateKind.unrecognized);
|
|
134
|
-
observableState.handledInput1.set(handled, tx);
|
|
135
|
-
observableState.handledInput2.set(handled, tx);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}));
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async initialize() {
|
|
143
|
-
if (this.options.resetResult) {
|
|
144
|
-
await this.reset();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
async reset() {
|
|
148
|
-
await waitForState(this.inputDiffComputingState, state => state === 2 );
|
|
149
|
-
const states = this.modifiedBaseRangeResultStates.get();
|
|
150
|
-
transaction(tx => {
|
|
151
|
-
for (const [range, state] of states) {
|
|
152
|
-
let newState;
|
|
153
|
-
let handled = false;
|
|
154
|
-
if (range.input1Diffs.length === 0) {
|
|
155
|
-
newState = ModifiedBaseRangeState.base.withInputValue(2, true);
|
|
156
|
-
handled = true;
|
|
157
|
-
}
|
|
158
|
-
else if (range.input2Diffs.length === 0) {
|
|
159
|
-
newState = ModifiedBaseRangeState.base.withInputValue(1, true);
|
|
160
|
-
handled = true;
|
|
161
|
-
}
|
|
162
|
-
else if (range.isEqualChange) {
|
|
163
|
-
newState = ModifiedBaseRangeState.base.withInputValue(1, true);
|
|
164
|
-
handled = true;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
newState = ModifiedBaseRangeState.base;
|
|
168
|
-
handled = false;
|
|
169
|
-
}
|
|
170
|
-
state.accepted.set(newState, tx);
|
|
171
|
-
state.computedFromDiffing = false;
|
|
172
|
-
state.previousNonDiffingState = undefined;
|
|
173
|
-
state.handledInput1.set(handled, tx);
|
|
174
|
-
state.handledInput2.set(handled, tx);
|
|
175
|
-
}
|
|
176
|
-
this.resultTextModel.pushEditOperations(null, [{
|
|
177
|
-
range: ( new Range(1, 1, Number.MAX_SAFE_INTEGER, 1)),
|
|
178
|
-
text: this.computeAutoMergedResult()
|
|
179
|
-
}], () => null);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
computeAutoMergedResult() {
|
|
183
|
-
const baseRanges = this.modifiedBaseRanges.get();
|
|
184
|
-
const baseLines = this.base.getLinesContent();
|
|
185
|
-
const input1Lines = this.input1.textModel.getLinesContent();
|
|
186
|
-
const input2Lines = this.input2.textModel.getLinesContent();
|
|
187
|
-
const resultLines = [];
|
|
188
|
-
function appendLinesToResult(source, lineRange) {
|
|
189
|
-
for (let i = lineRange.startLineNumber; i < lineRange.endLineNumberExclusive; i++) {
|
|
190
|
-
resultLines.push(source[i - 1]);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
let baseStartLineNumber = 1;
|
|
194
|
-
for (const baseRange of baseRanges) {
|
|
195
|
-
appendLinesToResult(baseLines, LineRange.fromLineNumbers(baseStartLineNumber, baseRange.baseRange.startLineNumber));
|
|
196
|
-
baseStartLineNumber = baseRange.baseRange.endLineNumberExclusive;
|
|
197
|
-
if (baseRange.input1Diffs.length === 0) {
|
|
198
|
-
appendLinesToResult(input2Lines, baseRange.input2Range);
|
|
199
|
-
}
|
|
200
|
-
else if (baseRange.input2Diffs.length === 0) {
|
|
201
|
-
appendLinesToResult(input1Lines, baseRange.input1Range);
|
|
202
|
-
}
|
|
203
|
-
else if (baseRange.isEqualChange) {
|
|
204
|
-
appendLinesToResult(input1Lines, baseRange.input1Range);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
appendLinesToResult(baseLines, baseRange.baseRange);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
appendLinesToResult(baseLines, LineRange.fromLineNumbers(baseStartLineNumber, baseLines.length + 1));
|
|
211
|
-
return resultLines.join(this.resultTextModel.getEOL());
|
|
212
|
-
}
|
|
213
|
-
hasBaseRange(baseRange) {
|
|
214
|
-
return ( this.modifiedBaseRangeResultStates.get().has(baseRange));
|
|
215
|
-
}
|
|
216
|
-
get isApplyingEditInResult() { return this.resultTextModelDiffs.isApplyingChange; }
|
|
217
|
-
getInputResultMapping(inputLinesDiffs, resultDiffs, inputLineCount) {
|
|
218
|
-
const map = DocumentLineRangeMap.betweenOutputs(inputLinesDiffs, resultDiffs, inputLineCount);
|
|
219
|
-
return ( new DocumentLineRangeMap(( map.lineRangeMappings.map((m) => m.inputRange.isEmpty || m.outputRange.isEmpty
|
|
220
|
-
? ( new LineRangeMapping(
|
|
221
|
-
m.inputRange.deltaStart(-1), m.outputRange.deltaStart(-1)))
|
|
222
|
-
: m)), map.inputLineCount));
|
|
223
|
-
}
|
|
224
|
-
translateInputRangeToBase(input, range) {
|
|
225
|
-
const baseInputDiffs = input === 1 ? this.baseInput1Diffs.get() : this.baseInput2Diffs.get();
|
|
226
|
-
const map = ( new DocumentRangeMap(baseInputDiffs.flatMap(d => d.rangeMappings), 0)).reverse();
|
|
227
|
-
return map.projectRange(range).outputRange;
|
|
228
|
-
}
|
|
229
|
-
translateBaseRangeToInput(input, range) {
|
|
230
|
-
const baseInputDiffs = input === 1 ? this.baseInput1Diffs.get() : this.baseInput2Diffs.get();
|
|
231
|
-
const map = ( new DocumentRangeMap(baseInputDiffs.flatMap(d => d.rangeMappings), 0));
|
|
232
|
-
return map.projectRange(range).outputRange;
|
|
233
|
-
}
|
|
234
|
-
getLineRangeInResult(baseRange, reader) {
|
|
235
|
-
return this.resultTextModelDiffs.getResultLineRange(baseRange, reader);
|
|
236
|
-
}
|
|
237
|
-
translateResultRangeToBase(range) {
|
|
238
|
-
const map = ( new DocumentRangeMap(this.baseResultDiffs.get().flatMap(d => d.rangeMappings), 0)).reverse();
|
|
239
|
-
return map.projectRange(range).outputRange;
|
|
240
|
-
}
|
|
241
|
-
translateBaseRangeToResult(range) {
|
|
242
|
-
const map = ( new DocumentRangeMap(this.baseResultDiffs.get().flatMap(d => d.rangeMappings), 0));
|
|
243
|
-
return map.projectRange(range).outputRange;
|
|
244
|
-
}
|
|
245
|
-
findModifiedBaseRangesInRange(rangeInBase) {
|
|
246
|
-
return this.modifiedBaseRanges.get().filter(r => r.baseRange.intersects(rangeInBase));
|
|
247
|
-
}
|
|
248
|
-
updateBaseRangeAcceptedState(resultDiffs, states, tx) {
|
|
249
|
-
const baseRangeWithStoreAndTouchingDiffs = leftJoin(states, resultDiffs, (baseRange, diff) => baseRange[0].baseRange.touches(diff.inputRange)
|
|
250
|
-
? CompareResult.neitherLessOrGreaterThan
|
|
251
|
-
: LineRange.compareByStart(baseRange[0].baseRange, diff.inputRange));
|
|
252
|
-
for (const row of baseRangeWithStoreAndTouchingDiffs) {
|
|
253
|
-
const newState = this.computeState(row.left[0], row.rights);
|
|
254
|
-
const data = row.left[1];
|
|
255
|
-
const oldState = data.accepted.get();
|
|
256
|
-
if (!oldState.equals(newState)) {
|
|
257
|
-
if (!this.firstRun && !data.computedFromDiffing) {
|
|
258
|
-
data.computedFromDiffing = true;
|
|
259
|
-
data.previousNonDiffingState = oldState;
|
|
260
|
-
}
|
|
261
|
-
data.accepted.set(newState, tx);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (this.firstRun) {
|
|
265
|
-
this.firstRun = false;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
computeState(baseRange, conflictingDiffs) {
|
|
269
|
-
if (conflictingDiffs.length === 0) {
|
|
270
|
-
return ModifiedBaseRangeState.base;
|
|
271
|
-
}
|
|
272
|
-
const conflictingEdits = ( conflictingDiffs.map((d) => d.getLineEdit()));
|
|
273
|
-
function editsAgreeWithDiffs(diffs) {
|
|
274
|
-
return equals(conflictingEdits, ( diffs.map((d) => d.getLineEdit())), (a, b) => a.equals(b));
|
|
275
|
-
}
|
|
276
|
-
if (editsAgreeWithDiffs(baseRange.input1Diffs)) {
|
|
277
|
-
return ModifiedBaseRangeState.base.withInputValue(1, true);
|
|
278
|
-
}
|
|
279
|
-
if (editsAgreeWithDiffs(baseRange.input2Diffs)) {
|
|
280
|
-
return ModifiedBaseRangeState.base.withInputValue(2, true);
|
|
281
|
-
}
|
|
282
|
-
const states = [
|
|
283
|
-
ModifiedBaseRangeState.base.withInputValue(1, true).withInputValue(2, true, true),
|
|
284
|
-
ModifiedBaseRangeState.base.withInputValue(2, true).withInputValue(1, true, true),
|
|
285
|
-
ModifiedBaseRangeState.base.withInputValue(1, true).withInputValue(2, true, false),
|
|
286
|
-
ModifiedBaseRangeState.base.withInputValue(2, true).withInputValue(1, true, false),
|
|
287
|
-
];
|
|
288
|
-
for (const s of states) {
|
|
289
|
-
const { edit } = baseRange.getEditForBase(s);
|
|
290
|
-
if (edit) {
|
|
291
|
-
const resultRange = this.resultTextModelDiffs.getResultLineRange(baseRange.baseRange);
|
|
292
|
-
const existingLines = resultRange.getLines(this.resultTextModel);
|
|
293
|
-
if (equals(edit.newLines, existingLines, (a, b) => a === b)) {
|
|
294
|
-
return s;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return ModifiedBaseRangeState.unrecognized;
|
|
299
|
-
}
|
|
300
|
-
getState(baseRange) {
|
|
301
|
-
const existingState = this.modifiedBaseRangeResultStates.get().get(baseRange);
|
|
302
|
-
if (!existingState) {
|
|
303
|
-
throw new BugIndicatingError('object must be from this instance');
|
|
304
|
-
}
|
|
305
|
-
return existingState.accepted;
|
|
306
|
-
}
|
|
307
|
-
setState(baseRange, state, _markInputAsHandled, tx, _pushStackElement = false) {
|
|
308
|
-
if (!this.isUpToDate.get()) {
|
|
309
|
-
throw new BugIndicatingError('Cannot set state while updating');
|
|
310
|
-
}
|
|
311
|
-
const existingState = this.modifiedBaseRangeResultStates.get().get(baseRange);
|
|
312
|
-
if (!existingState) {
|
|
313
|
-
throw new BugIndicatingError('object must be from this instance');
|
|
314
|
-
}
|
|
315
|
-
const conflictingDiffs = this.resultTextModelDiffs.findTouchingDiffs(baseRange.baseRange);
|
|
316
|
-
const group = ( new UndoRedoGroup());
|
|
317
|
-
if (conflictingDiffs) {
|
|
318
|
-
this.resultTextModelDiffs.removeDiffs(conflictingDiffs, tx, group);
|
|
319
|
-
}
|
|
320
|
-
const { edit, effectiveState } = baseRange.getEditForBase(state);
|
|
321
|
-
existingState.accepted.set(effectiveState, tx);
|
|
322
|
-
existingState.previousNonDiffingState = undefined;
|
|
323
|
-
existingState.computedFromDiffing = false;
|
|
324
|
-
const input1Handled = existingState.handledInput1.get();
|
|
325
|
-
const input2Handled = existingState.handledInput2.get();
|
|
326
|
-
if (!input1Handled || !input2Handled) {
|
|
327
|
-
this.undoRedoService.pushElement(( new MarkAsHandledUndoRedoElement(this.resultTextModel.uri, ( new WeakRef(this)), ( new WeakRef(existingState)), input1Handled, input2Handled)), group);
|
|
328
|
-
}
|
|
329
|
-
if (edit) {
|
|
330
|
-
this.resultTextModel.pushStackElement();
|
|
331
|
-
this.resultTextModelDiffs.applyEditRelativeToOriginal(edit, tx, group);
|
|
332
|
-
this.resultTextModel.pushStackElement();
|
|
333
|
-
}
|
|
334
|
-
existingState.handledInput1.set(true, tx);
|
|
335
|
-
existingState.handledInput2.set(true, tx);
|
|
336
|
-
}
|
|
337
|
-
resetDirtyConflictsToBase() {
|
|
338
|
-
transaction(tx => {
|
|
339
|
-
this.resultTextModel.pushStackElement();
|
|
340
|
-
for (const range of this.modifiedBaseRanges.get()) {
|
|
341
|
-
if (this.getState(range).get().kind === ModifiedBaseRangeStateKind.unrecognized) {
|
|
342
|
-
this.setState(range, ModifiedBaseRangeState.base, false, tx, false);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
this.resultTextModel.pushStackElement();
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
isHandled(baseRange) {
|
|
349
|
-
return this.modifiedBaseRangeResultStates.get().get(baseRange).handled;
|
|
350
|
-
}
|
|
351
|
-
isInputHandled(baseRange, inputNumber) {
|
|
352
|
-
const state = this.modifiedBaseRangeResultStates.get().get(baseRange);
|
|
353
|
-
return inputNumber === 1 ? state.handledInput1 : state.handledInput2;
|
|
354
|
-
}
|
|
355
|
-
setInputHandled(baseRange, inputNumber, handled, tx) {
|
|
356
|
-
const state = this.modifiedBaseRangeResultStates.get().get(baseRange);
|
|
357
|
-
if (state.handled.get() === handled) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
const dataRef = ( new WeakRef(ModifiedBaseRangeData));
|
|
361
|
-
const modelRef = ( new WeakRef(this));
|
|
362
|
-
this.undoRedoService.pushElement({
|
|
363
|
-
type: 0 ,
|
|
364
|
-
resource: this.resultTextModel.uri,
|
|
365
|
-
code: 'setInputHandled',
|
|
366
|
-
label: ( localizeWithPath(
|
|
367
|
-
'vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel',
|
|
368
|
-
'setInputHandled',
|
|
369
|
-
"Set Input Handled"
|
|
370
|
-
)),
|
|
371
|
-
redo() {
|
|
372
|
-
const model = modelRef.deref();
|
|
373
|
-
const data = dataRef.deref();
|
|
374
|
-
if (model && !model.isDisposed() && data) {
|
|
375
|
-
transaction(tx => {
|
|
376
|
-
if (inputNumber === 1) {
|
|
377
|
-
state.handledInput1.set(handled, tx);
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
state.handledInput2.set(handled, tx);
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
undo() {
|
|
386
|
-
const model = modelRef.deref();
|
|
387
|
-
const data = dataRef.deref();
|
|
388
|
-
if (model && !model.isDisposed() && data) {
|
|
389
|
-
transaction(tx => {
|
|
390
|
-
if (inputNumber === 1) {
|
|
391
|
-
state.handledInput1.set(!handled, tx);
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
state.handledInput2.set(!handled, tx);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
});
|
|
400
|
-
if (inputNumber === 1) {
|
|
401
|
-
state.handledInput1.set(handled, tx);
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
state.handledInput2.set(handled, tx);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
setHandled(baseRange, handled, tx) {
|
|
408
|
-
const state = this.modifiedBaseRangeResultStates.get().get(baseRange);
|
|
409
|
-
if (state.handled.get() === handled) {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
state.handledInput1.set(handled, tx);
|
|
413
|
-
state.handledInput2.set(handled, tx);
|
|
414
|
-
}
|
|
415
|
-
setLanguageId(languageId, source) {
|
|
416
|
-
const language = this.languageService.createById(languageId);
|
|
417
|
-
this.base.setLanguage(language, source);
|
|
418
|
-
this.input1.textModel.setLanguage(language, source);
|
|
419
|
-
this.input2.textModel.setLanguage(language, source);
|
|
420
|
-
this.resultTextModel.setLanguage(language, source);
|
|
421
|
-
}
|
|
422
|
-
getInitialResultValue() {
|
|
423
|
-
const chunks = [];
|
|
424
|
-
while (true) {
|
|
425
|
-
const chunk = this.resultSnapshot.read();
|
|
426
|
-
if (chunk === null) {
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
chunks.push(chunk);
|
|
430
|
-
}
|
|
431
|
-
return chunks.join();
|
|
432
|
-
}
|
|
433
|
-
async getResultValueWithConflictMarkers() {
|
|
434
|
-
await waitForState(this.diffComputingState, state => state === 2 );
|
|
435
|
-
if (this.unhandledConflictsCount.get() === 0) {
|
|
436
|
-
return this.resultTextModel.getValue();
|
|
437
|
-
}
|
|
438
|
-
const resultLines = this.resultTextModel.getLinesContent();
|
|
439
|
-
const input1Lines = this.input1.textModel.getLinesContent();
|
|
440
|
-
const input2Lines = this.input2.textModel.getLinesContent();
|
|
441
|
-
const states = this.modifiedBaseRangeResultStates.get();
|
|
442
|
-
const outputLines = [];
|
|
443
|
-
function appendLinesToResult(source, lineRange) {
|
|
444
|
-
for (let i = lineRange.startLineNumber; i < lineRange.endLineNumberExclusive; i++) {
|
|
445
|
-
outputLines.push(source[i - 1]);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
let resultStartLineNumber = 1;
|
|
449
|
-
for (const [range, state] of states) {
|
|
450
|
-
if (state.handled.get()) {
|
|
451
|
-
continue;
|
|
452
|
-
}
|
|
453
|
-
const resultRange = this.resultTextModelDiffs.getResultLineRange(range.baseRange);
|
|
454
|
-
appendLinesToResult(resultLines, LineRange.fromLineNumbers(resultStartLineNumber, Math.max(resultStartLineNumber, resultRange.startLineNumber)));
|
|
455
|
-
resultStartLineNumber = resultRange.endLineNumberExclusive;
|
|
456
|
-
outputLines.push('<<<<<<<');
|
|
457
|
-
if (state.accepted.get().kind === ModifiedBaseRangeStateKind.unrecognized) {
|
|
458
|
-
appendLinesToResult(resultLines, resultRange);
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
appendLinesToResult(input1Lines, range.input1Range);
|
|
462
|
-
}
|
|
463
|
-
outputLines.push('=======');
|
|
464
|
-
appendLinesToResult(input2Lines, range.input2Range);
|
|
465
|
-
outputLines.push('>>>>>>>');
|
|
466
|
-
}
|
|
467
|
-
appendLinesToResult(resultLines, LineRange.fromLineNumbers(resultStartLineNumber, resultLines.length + 1));
|
|
468
|
-
return outputLines.join('\n');
|
|
469
|
-
}
|
|
470
|
-
get conflictCount() {
|
|
471
|
-
return arrayCount(this.modifiedBaseRanges.get(), r => r.isConflicting);
|
|
472
|
-
}
|
|
473
|
-
get combinableConflictCount() {
|
|
474
|
-
return arrayCount(this.modifiedBaseRanges.get(), r => r.isConflicting && r.canBeCombined);
|
|
475
|
-
}
|
|
476
|
-
get conflictsResolvedWithBase() {
|
|
477
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => r.isConflicting &&
|
|
478
|
-
s.accepted.get().kind === ModifiedBaseRangeStateKind.base);
|
|
479
|
-
}
|
|
480
|
-
get conflictsResolvedWithInput1() {
|
|
481
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => r.isConflicting &&
|
|
482
|
-
s.accepted.get().kind === ModifiedBaseRangeStateKind.input1);
|
|
483
|
-
}
|
|
484
|
-
get conflictsResolvedWithInput2() {
|
|
485
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => r.isConflicting &&
|
|
486
|
-
s.accepted.get().kind === ModifiedBaseRangeStateKind.input2);
|
|
487
|
-
}
|
|
488
|
-
get conflictsResolvedWithSmartCombination() {
|
|
489
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
490
|
-
const state = s.accepted.get();
|
|
491
|
-
return r.isConflicting && state.kind === ModifiedBaseRangeStateKind.both && state.smartCombination;
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
get manuallySolvedConflictCountThatEqualNone() {
|
|
495
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => r.isConflicting &&
|
|
496
|
-
s.accepted.get().kind === ModifiedBaseRangeStateKind.unrecognized);
|
|
497
|
-
}
|
|
498
|
-
get manuallySolvedConflictCountThatEqualSmartCombine() {
|
|
499
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
500
|
-
const state = s.accepted.get();
|
|
501
|
-
return r.isConflicting && s.computedFromDiffing && state.kind === ModifiedBaseRangeStateKind.both && state.smartCombination;
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
get manuallySolvedConflictCountThatEqualInput1() {
|
|
505
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
506
|
-
const state = s.accepted.get();
|
|
507
|
-
return r.isConflicting && s.computedFromDiffing && state.kind === ModifiedBaseRangeStateKind.input1;
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
get manuallySolvedConflictCountThatEqualInput2() {
|
|
511
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
512
|
-
const state = s.accepted.get();
|
|
513
|
-
return r.isConflicting && s.computedFromDiffing && state.kind === ModifiedBaseRangeStateKind.input2;
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
get manuallySolvedConflictCountThatEqualNoneAndStartedWithBase() {
|
|
517
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
518
|
-
const state = s.accepted.get();
|
|
519
|
-
return r.isConflicting && state.kind === ModifiedBaseRangeStateKind.unrecognized && s.previousNonDiffingState?.kind === ModifiedBaseRangeStateKind.base;
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
get manuallySolvedConflictCountThatEqualNoneAndStartedWithInput1() {
|
|
523
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
524
|
-
const state = s.accepted.get();
|
|
525
|
-
return r.isConflicting && state.kind === ModifiedBaseRangeStateKind.unrecognized && s.previousNonDiffingState?.kind === ModifiedBaseRangeStateKind.input1;
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
get manuallySolvedConflictCountThatEqualNoneAndStartedWithInput2() {
|
|
529
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
530
|
-
const state = s.accepted.get();
|
|
531
|
-
return r.isConflicting && state.kind === ModifiedBaseRangeStateKind.unrecognized && s.previousNonDiffingState?.kind === ModifiedBaseRangeStateKind.input2;
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
get manuallySolvedConflictCountThatEqualNoneAndStartedWithBothNonSmart() {
|
|
535
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
536
|
-
const state = s.accepted.get();
|
|
537
|
-
return r.isConflicting && state.kind === ModifiedBaseRangeStateKind.unrecognized && s.previousNonDiffingState?.kind === ModifiedBaseRangeStateKind.both && !s.previousNonDiffingState?.smartCombination;
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
get manuallySolvedConflictCountThatEqualNoneAndStartedWithBothSmart() {
|
|
541
|
-
return arrayCount(this.modifiedBaseRangeResultStates.get().entries(), ([r, s]) => {
|
|
542
|
-
const state = s.accepted.get();
|
|
543
|
-
return r.isConflicting && state.kind === ModifiedBaseRangeStateKind.unrecognized && s.previousNonDiffingState?.kind === ModifiedBaseRangeStateKind.both && s.previousNonDiffingState?.smartCombination;
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
MergeEditorModel = ( __decorate([
|
|
548
|
-
( __param(7, ILanguageService)),
|
|
549
|
-
( __param(8, IUndoRedoService))
|
|
550
|
-
], MergeEditorModel));
|
|
551
|
-
function arrayCount(array, predicate) {
|
|
552
|
-
let count = 0;
|
|
553
|
-
for (const value of array) {
|
|
554
|
-
if (predicate(value)) {
|
|
555
|
-
count++;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
return count;
|
|
559
|
-
}
|
|
560
|
-
class ModifiedBaseRangeData {
|
|
561
|
-
constructor(baseRange) {
|
|
562
|
-
this.baseRange = baseRange;
|
|
563
|
-
this.accepted = observableValue(`BaseRangeState${this.baseRange.baseRange}`, ModifiedBaseRangeState.base);
|
|
564
|
-
this.handledInput1 = observableValue(`BaseRangeHandledState${this.baseRange.baseRange}.Input1`, false);
|
|
565
|
-
this.handledInput2 = observableValue(`BaseRangeHandledState${this.baseRange.baseRange}.Input2`, false);
|
|
566
|
-
this.computedFromDiffing = false;
|
|
567
|
-
this.previousNonDiffingState = undefined;
|
|
568
|
-
this.handled = derived(this, reader => this.handledInput1.read(reader) && this.handledInput2.read(reader));
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
class MarkAsHandledUndoRedoElement {
|
|
572
|
-
constructor(resource, mergeEditorModelRef, stateRef, input1Handled, input2Handled) {
|
|
573
|
-
this.resource = resource;
|
|
574
|
-
this.mergeEditorModelRef = mergeEditorModelRef;
|
|
575
|
-
this.stateRef = stateRef;
|
|
576
|
-
this.input1Handled = input1Handled;
|
|
577
|
-
this.input2Handled = input2Handled;
|
|
578
|
-
this.code = 'undoMarkAsHandled';
|
|
579
|
-
this.label = ( localizeWithPath(
|
|
580
|
-
'vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel',
|
|
581
|
-
'undoMarkAsHandled',
|
|
582
|
-
'Undo Mark As Handled'
|
|
583
|
-
));
|
|
584
|
-
this.type = 0 ;
|
|
585
|
-
}
|
|
586
|
-
redo() {
|
|
587
|
-
const mergeEditorModel = this.mergeEditorModelRef.deref();
|
|
588
|
-
if (!mergeEditorModel || mergeEditorModel.isDisposed()) {
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
const state = this.stateRef.deref();
|
|
592
|
-
if (!state) {
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
transaction(tx => {
|
|
596
|
-
state.handledInput1.set(true, tx);
|
|
597
|
-
state.handledInput2.set(true, tx);
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
undo() {
|
|
601
|
-
const mergeEditorModel = this.mergeEditorModelRef.deref();
|
|
602
|
-
if (!mergeEditorModel || mergeEditorModel.isDisposed()) {
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
const state = this.stateRef.deref();
|
|
606
|
-
if (!state) {
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
transaction(tx => {
|
|
610
|
-
state.handledInput1.set(this.input1Handled, tx);
|
|
611
|
-
state.handledInput2.set(this.input2Handled, tx);
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
export { MergeEditorModel };
|