@codingame/monaco-vscode-a793b3ee-7ba9-5176-a019-30ec806fdd95-common 20.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/empty.js +1 -0
- package/package.json +50 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.d.ts +159 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +1318 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.d.ts +172 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +482 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.d.ts +86 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +377 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.d.ts +70 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +456 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.d.ts +40 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.js +276 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.d.ts +22 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +318 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.d.ts +18 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.d.ts +69 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +318 -0
@@ -0,0 +1,456 @@
|
|
1
|
+
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
3
|
+
import { WindowIntervalTimer, createElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
4
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
5
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
6
|
+
import { themeColorFromId, ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
7
|
+
import { StableEditorScrollState } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/stableEditorScroll';
|
8
|
+
import { RenderOptions, LineSource, renderLines } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/renderLines';
|
9
|
+
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/ranges/lineRange';
|
10
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
11
|
+
import { MinimapPosition, OverviewRulerLane, TrackedRangeStickiness } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
|
12
|
+
import { ModelDecorationOptions } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
|
13
|
+
import { IEditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker.service';
|
14
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
15
|
+
import { Progress } from '@codingame/monaco-vscode-api/vscode/vs/platform/progress/common/progress';
|
16
|
+
import { SaveReason } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
17
|
+
import { countWords } from '@codingame/monaco-vscode-c2deffc4-ad68-5e63-8f95-9b89e0fc6898-common/vscode/vs/workbench/contrib/chat/common/chatWordCounter';
|
18
|
+
import { HunkState } from './inlineChatSession.js';
|
19
|
+
import { minimapInlineChatDiffInserted, overviewRulerInlineChatDiffInserted, CTX_INLINE_CHAT_CHANGE_HAS_DIFF, CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF, MENU_INLINE_CHAT_ZONE, ACTION_TOGGLE_DIFF, InlineChatConfigKeys } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
20
|
+
import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
21
|
+
import { asProgressiveEdit, performAsyncTextEdit } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/inlineChat/browser/utils';
|
22
|
+
import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
|
23
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
24
|
+
import { ITextFileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
25
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
26
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
27
|
+
import { DefaultChatTextEditor } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/chat/browser/codeBlockPart';
|
28
|
+
import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
29
|
+
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
30
|
+
import { ConflictActionsFactory } from '@codingame/monaco-vscode-6db1b967-5327-5c5c-8c17-bd92774c0fb2-common/vscode/vs/workbench/contrib/mergeEditor/browser/view/conflictActions';
|
31
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
32
|
+
import { MenuItemAction } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
33
|
+
import { IMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions.service';
|
34
|
+
import { InlineDecoration, InlineDecorationType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/viewModel/inlineDecorations';
|
35
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
36
|
+
|
37
|
+
var HunkAction;
|
38
|
+
(function (HunkAction) {
|
39
|
+
HunkAction[HunkAction["Accept"] = 0] = "Accept";
|
40
|
+
HunkAction[HunkAction["Discard"] = 1] = "Discard";
|
41
|
+
HunkAction[HunkAction["MoveNext"] = 2] = "MoveNext";
|
42
|
+
HunkAction[HunkAction["MovePrev"] = 3] = "MovePrev";
|
43
|
+
HunkAction[HunkAction["ToggleDiff"] = 4] = "ToggleDiff";
|
44
|
+
})(HunkAction || (HunkAction = {}));
|
45
|
+
let LiveStrategy = class LiveStrategy {
|
46
|
+
constructor(_session, _editor, _zone, _showOverlayToolbar, contextKeyService, _editorWorkerService, _accessibilityService, _configService, _menuService, _contextService, _textFileService, _instaService) {
|
47
|
+
this._session = _session;
|
48
|
+
this._editor = _editor;
|
49
|
+
this._zone = _zone;
|
50
|
+
this._showOverlayToolbar = _showOverlayToolbar;
|
51
|
+
this._editorWorkerService = _editorWorkerService;
|
52
|
+
this._accessibilityService = _accessibilityService;
|
53
|
+
this._configService = _configService;
|
54
|
+
this._menuService = _menuService;
|
55
|
+
this._contextService = _contextService;
|
56
|
+
this._textFileService = _textFileService;
|
57
|
+
this._instaService = _instaService;
|
58
|
+
this._decoInsertedText = ModelDecorationOptions.register({
|
59
|
+
description: 'inline-modified-line',
|
60
|
+
className: 'inline-chat-inserted-range-linehighlight',
|
61
|
+
isWholeLine: true,
|
62
|
+
overviewRuler: {
|
63
|
+
position: OverviewRulerLane.Full,
|
64
|
+
color: themeColorFromId(overviewRulerInlineChatDiffInserted),
|
65
|
+
},
|
66
|
+
minimap: {
|
67
|
+
position: MinimapPosition.Inline,
|
68
|
+
color: themeColorFromId(minimapInlineChatDiffInserted),
|
69
|
+
}
|
70
|
+
});
|
71
|
+
this._decoInsertedTextRange = ModelDecorationOptions.register({
|
72
|
+
description: 'inline-chat-inserted-range-linehighlight',
|
73
|
+
className: 'inline-chat-inserted-range',
|
74
|
+
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
75
|
+
});
|
76
|
+
this._store = ( new DisposableStore());
|
77
|
+
this._onDidAccept = this._store.add(( new Emitter()));
|
78
|
+
this._onDidDiscard = this._store.add(( new Emitter()));
|
79
|
+
this._editCount = 0;
|
80
|
+
this._hunkData = ( new Map());
|
81
|
+
this.onDidAccept = this._onDidAccept.event;
|
82
|
+
this.onDidDiscard = this._onDidDiscard.event;
|
83
|
+
this._ctxCurrentChangeHasDiff = CTX_INLINE_CHAT_CHANGE_HAS_DIFF.bindTo(contextKeyService);
|
84
|
+
this._ctxCurrentChangeShowsDiff = CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF.bindTo(contextKeyService);
|
85
|
+
this._progressiveEditingDecorations = this._editor.createDecorationsCollection();
|
86
|
+
this._lensActionsFactory = this._store.add(( new ConflictActionsFactory(this._editor)));
|
87
|
+
}
|
88
|
+
dispose() {
|
89
|
+
this._resetDiff();
|
90
|
+
this._store.dispose();
|
91
|
+
}
|
92
|
+
_resetDiff() {
|
93
|
+
this._ctxCurrentChangeHasDiff.reset();
|
94
|
+
this._ctxCurrentChangeShowsDiff.reset();
|
95
|
+
this._zone.widget.updateStatus('');
|
96
|
+
this._progressiveEditingDecorations.clear();
|
97
|
+
for (const data of ( this._hunkData.values())) {
|
98
|
+
data.remove();
|
99
|
+
}
|
100
|
+
}
|
101
|
+
async apply() {
|
102
|
+
this._resetDiff();
|
103
|
+
if (this._editCount > 0) {
|
104
|
+
this._editor.pushUndoStop();
|
105
|
+
}
|
106
|
+
await this._doApplyChanges(true);
|
107
|
+
}
|
108
|
+
cancel() {
|
109
|
+
this._resetDiff();
|
110
|
+
return this._session.hunkData.discardAll();
|
111
|
+
}
|
112
|
+
async makeChanges(edits, obs, undoStopBefore) {
|
113
|
+
return this._makeChanges(edits, obs, undefined, undefined, undoStopBefore);
|
114
|
+
}
|
115
|
+
async makeProgressiveChanges(edits, obs, opts, undoStopBefore) {
|
116
|
+
const progress = ( new Progress(edits => {
|
117
|
+
const newLines = ( new Set());
|
118
|
+
for (const edit of edits) {
|
119
|
+
LineRange.fromRange(edit.range).forEach(line => newLines.add(line));
|
120
|
+
}
|
121
|
+
const existingRanges = ( this._progressiveEditingDecorations.getRanges().map(LineRange.fromRange));
|
122
|
+
for (const existingRange of existingRanges) {
|
123
|
+
existingRange.forEach(line => newLines.delete(line));
|
124
|
+
}
|
125
|
+
const newDecorations = [];
|
126
|
+
for (const line of newLines) {
|
127
|
+
newDecorations.push({ range: ( new Range(line, 1, line, Number.MAX_VALUE)), options: this._decoInsertedText });
|
128
|
+
}
|
129
|
+
this._progressiveEditingDecorations.append(newDecorations);
|
130
|
+
}));
|
131
|
+
return this._makeChanges(edits, obs, opts, progress, undoStopBefore);
|
132
|
+
}
|
133
|
+
async _makeChanges(edits, obs, opts, progress, undoStopBefore) {
|
134
|
+
if (undoStopBefore) {
|
135
|
+
this._editor.pushUndoStop();
|
136
|
+
}
|
137
|
+
this._editCount++;
|
138
|
+
if (opts) {
|
139
|
+
const durationInSec = opts.duration / 1000;
|
140
|
+
for (const edit of edits) {
|
141
|
+
const wordCount = countWords(edit.text ?? '');
|
142
|
+
const speed = wordCount / durationInSec;
|
143
|
+
const asyncEdit = asProgressiveEdit(( new WindowIntervalTimer(this._zone.domNode)), edit, speed, opts.token);
|
144
|
+
await performAsyncTextEdit(this._session.textModelN, asyncEdit, progress, obs);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
obs.start();
|
149
|
+
this._session.textModelN.pushEditOperations(null, edits, (undoEdits) => {
|
150
|
+
progress?.report(undoEdits);
|
151
|
+
return null;
|
152
|
+
});
|
153
|
+
obs.stop();
|
154
|
+
}
|
155
|
+
}
|
156
|
+
performHunkAction(hunk, action) {
|
157
|
+
const displayData = this._findDisplayData(hunk);
|
158
|
+
if (!displayData) {
|
159
|
+
if (action === HunkAction.Accept) {
|
160
|
+
this._onDidAccept.fire();
|
161
|
+
}
|
162
|
+
else if (action === HunkAction.Discard) {
|
163
|
+
this._onDidDiscard.fire();
|
164
|
+
}
|
165
|
+
return;
|
166
|
+
}
|
167
|
+
if (action === HunkAction.Accept) {
|
168
|
+
displayData.acceptHunk();
|
169
|
+
}
|
170
|
+
else if (action === HunkAction.Discard) {
|
171
|
+
displayData.discardHunk();
|
172
|
+
}
|
173
|
+
else if (action === HunkAction.MoveNext) {
|
174
|
+
displayData.move(true);
|
175
|
+
}
|
176
|
+
else if (action === HunkAction.MovePrev) {
|
177
|
+
displayData.move(false);
|
178
|
+
}
|
179
|
+
else if (action === HunkAction.ToggleDiff) {
|
180
|
+
displayData.toggleDiff?.();
|
181
|
+
}
|
182
|
+
}
|
183
|
+
_findDisplayData(hunkInfo) {
|
184
|
+
let result;
|
185
|
+
if (hunkInfo) {
|
186
|
+
result = this._hunkData.get(hunkInfo);
|
187
|
+
}
|
188
|
+
if (!result && this._zone.position) {
|
189
|
+
const zoneLine = this._zone.position.lineNumber;
|
190
|
+
let distance = Number.MAX_SAFE_INTEGER;
|
191
|
+
for (const candidate of ( this._hunkData.values())) {
|
192
|
+
if (candidate.hunk.getState() !== HunkState.Pending) {
|
193
|
+
continue;
|
194
|
+
}
|
195
|
+
const hunkRanges = candidate.hunk.getRangesN();
|
196
|
+
if (hunkRanges.length === 0) {
|
197
|
+
continue;
|
198
|
+
}
|
199
|
+
const myDistance = zoneLine <= hunkRanges[0].startLineNumber
|
200
|
+
? hunkRanges[0].startLineNumber - zoneLine
|
201
|
+
: zoneLine - hunkRanges[0].endLineNumber;
|
202
|
+
if (myDistance < distance) {
|
203
|
+
distance = myDistance;
|
204
|
+
result = candidate;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
if (!result) {
|
209
|
+
result = Iterable.first(Iterable.filter(( this._hunkData.values()), candidate => candidate.hunk.getState() === HunkState.Pending));
|
210
|
+
}
|
211
|
+
return result;
|
212
|
+
}
|
213
|
+
async renderChanges() {
|
214
|
+
this._progressiveEditingDecorations.clear();
|
215
|
+
const renderHunks = () => {
|
216
|
+
let widgetData;
|
217
|
+
changeDecorationsAndViewZones(this._editor, (decorationsAccessor, viewZoneAccessor) => {
|
218
|
+
const keysNow = ( new Set(( this._hunkData.keys())));
|
219
|
+
widgetData = undefined;
|
220
|
+
for (const hunkData of this._session.hunkData.getInfo()) {
|
221
|
+
keysNow.delete(hunkData);
|
222
|
+
const hunkRanges = hunkData.getRangesN();
|
223
|
+
let data = this._hunkData.get(hunkData);
|
224
|
+
if (!data) {
|
225
|
+
const decorationIds = [];
|
226
|
+
for (let i = 0; i < hunkRanges.length; i++) {
|
227
|
+
decorationIds.push(decorationsAccessor.addDecoration(hunkRanges[i], i === 0
|
228
|
+
? this._decoInsertedText
|
229
|
+
: this._decoInsertedTextRange));
|
230
|
+
}
|
231
|
+
const acceptHunk = () => {
|
232
|
+
hunkData.acceptChanges();
|
233
|
+
renderHunks();
|
234
|
+
};
|
235
|
+
const discardHunk = () => {
|
236
|
+
hunkData.discardChanges();
|
237
|
+
renderHunks();
|
238
|
+
};
|
239
|
+
const mightContainNonBasicASCII = this._session.textModel0.mightContainNonBasicASCII();
|
240
|
+
const mightContainRTL = this._session.textModel0.mightContainRTL();
|
241
|
+
const renderOptions = RenderOptions.fromEditor(this._editor);
|
242
|
+
const originalRange = hunkData.getRanges0()[0];
|
243
|
+
const source = ( new LineSource(
|
244
|
+
LineRange.fromRangeInclusive(originalRange).mapToLineArray(l => this._session.textModel0.tokenization.getLineTokens(l)),
|
245
|
+
[],
|
246
|
+
mightContainNonBasicASCII,
|
247
|
+
mightContainRTL
|
248
|
+
));
|
249
|
+
const domNode = createElement('div');
|
250
|
+
domNode.className = 'inline-chat-original-zone2';
|
251
|
+
const result = renderLines(source, renderOptions, [( new InlineDecoration(( new Range(originalRange.startLineNumber, 1, originalRange.startLineNumber, 1)), '', InlineDecorationType.Regular))], domNode);
|
252
|
+
const viewZoneData = {
|
253
|
+
afterLineNumber: -1,
|
254
|
+
heightInLines: result.heightInLines,
|
255
|
+
domNode,
|
256
|
+
ordinal: 50000 + 2
|
257
|
+
};
|
258
|
+
const toggleDiff = () => {
|
259
|
+
const scrollState = StableEditorScrollState.capture(this._editor);
|
260
|
+
changeDecorationsAndViewZones(this._editor, (_decorationsAccessor, viewZoneAccessor) => {
|
261
|
+
assertType(data);
|
262
|
+
if (!data.diffViewZoneId) {
|
263
|
+
const [hunkRange] = hunkData.getRangesN();
|
264
|
+
viewZoneData.afterLineNumber = hunkRange.startLineNumber - 1;
|
265
|
+
data.diffViewZoneId = viewZoneAccessor.addZone(viewZoneData);
|
266
|
+
}
|
267
|
+
else {
|
268
|
+
viewZoneAccessor.removeZone(data.diffViewZoneId);
|
269
|
+
data.diffViewZoneId = undefined;
|
270
|
+
}
|
271
|
+
});
|
272
|
+
this._ctxCurrentChangeShowsDiff.set(typeof data?.diffViewZoneId === 'string');
|
273
|
+
scrollState.restore(this._editor);
|
274
|
+
};
|
275
|
+
let lensActions;
|
276
|
+
const lensActionsViewZoneIds = [];
|
277
|
+
if (this._showOverlayToolbar && hunkData.getState() === HunkState.Pending) {
|
278
|
+
lensActions = ( new DisposableStore());
|
279
|
+
const menu = this._menuService.createMenu(MENU_INLINE_CHAT_ZONE, this._contextService);
|
280
|
+
const makeActions = () => {
|
281
|
+
const actions = [];
|
282
|
+
const tuples = menu.getActions({ arg: hunkData });
|
283
|
+
for (const [, group] of tuples) {
|
284
|
+
for (const item of group) {
|
285
|
+
if (item instanceof MenuItemAction) {
|
286
|
+
let text = item.label;
|
287
|
+
if (item.id === ACTION_TOGGLE_DIFF) {
|
288
|
+
text = item.checked ? 'Hide Changes' : 'Show Changes';
|
289
|
+
}
|
290
|
+
else if (ThemeIcon.isThemeIcon(item.item.icon)) {
|
291
|
+
text = `$(${item.item.icon.id}) ${text}`;
|
292
|
+
}
|
293
|
+
actions.push({
|
294
|
+
text,
|
295
|
+
tooltip: item.tooltip,
|
296
|
+
action: async () => item.run(),
|
297
|
+
});
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}
|
301
|
+
return actions;
|
302
|
+
};
|
303
|
+
const obs = observableValue(this, makeActions());
|
304
|
+
lensActions.add(menu.onDidChange(() => obs.set(makeActions(), undefined)));
|
305
|
+
lensActions.add(menu);
|
306
|
+
lensActions.add(this._lensActionsFactory.createWidget(viewZoneAccessor, hunkRanges[0].startLineNumber - 1, obs, lensActionsViewZoneIds));
|
307
|
+
}
|
308
|
+
const remove = () => {
|
309
|
+
changeDecorationsAndViewZones(this._editor, (decorationsAccessor, viewZoneAccessor) => {
|
310
|
+
assertType(data);
|
311
|
+
for (const decorationId of data.decorationIds) {
|
312
|
+
decorationsAccessor.removeDecoration(decorationId);
|
313
|
+
}
|
314
|
+
if (data.diffViewZoneId) {
|
315
|
+
viewZoneAccessor.removeZone(data.diffViewZoneId);
|
316
|
+
}
|
317
|
+
data.decorationIds = [];
|
318
|
+
data.diffViewZoneId = undefined;
|
319
|
+
data.lensActionsViewZoneIds?.forEach(viewZoneAccessor.removeZone);
|
320
|
+
data.lensActionsViewZoneIds = undefined;
|
321
|
+
});
|
322
|
+
lensActions?.dispose();
|
323
|
+
};
|
324
|
+
const move = (next) => {
|
325
|
+
const keys = Array.from(( this._hunkData.keys()));
|
326
|
+
const idx = keys.indexOf(hunkData);
|
327
|
+
const nextIdx = (idx + (next ? 1 : -1) + keys.length) % keys.length;
|
328
|
+
if (nextIdx !== idx) {
|
329
|
+
const nextData = this._hunkData.get(keys[nextIdx]);
|
330
|
+
this._zone.updatePositionAndHeight(nextData?.position);
|
331
|
+
renderHunks();
|
332
|
+
}
|
333
|
+
};
|
334
|
+
const zoneLineNumber = this._zone.position?.lineNumber ?? this._editor.getPosition().lineNumber;
|
335
|
+
const myDistance = zoneLineNumber <= hunkRanges[0].startLineNumber
|
336
|
+
? hunkRanges[0].startLineNumber - zoneLineNumber
|
337
|
+
: zoneLineNumber - hunkRanges[0].endLineNumber;
|
338
|
+
data = {
|
339
|
+
hunk: hunkData,
|
340
|
+
decorationIds,
|
341
|
+
diffViewZoneId: '',
|
342
|
+
diffViewZone: viewZoneData,
|
343
|
+
lensActionsViewZoneIds,
|
344
|
+
distance: myDistance,
|
345
|
+
position: hunkRanges[0].getStartPosition().delta(-1),
|
346
|
+
acceptHunk,
|
347
|
+
discardHunk,
|
348
|
+
toggleDiff: !hunkData.isInsertion() ? toggleDiff : undefined,
|
349
|
+
remove,
|
350
|
+
move,
|
351
|
+
};
|
352
|
+
this._hunkData.set(hunkData, data);
|
353
|
+
}
|
354
|
+
else if (hunkData.getState() !== HunkState.Pending) {
|
355
|
+
data.remove();
|
356
|
+
}
|
357
|
+
else {
|
358
|
+
const zoneLineNumber = this._zone.position?.lineNumber ?? this._editor.getPosition().lineNumber;
|
359
|
+
const modifiedRangeNow = hunkRanges[0];
|
360
|
+
data.position = modifiedRangeNow.getStartPosition().delta(-1);
|
361
|
+
data.distance = zoneLineNumber <= modifiedRangeNow.startLineNumber
|
362
|
+
? modifiedRangeNow.startLineNumber - zoneLineNumber
|
363
|
+
: zoneLineNumber - modifiedRangeNow.endLineNumber;
|
364
|
+
}
|
365
|
+
if (hunkData.getState() === HunkState.Pending && (!widgetData || data.distance < widgetData.distance)) {
|
366
|
+
widgetData = data;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
for (const key of keysNow) {
|
370
|
+
const data = this._hunkData.get(key);
|
371
|
+
if (data) {
|
372
|
+
this._hunkData.delete(key);
|
373
|
+
data.remove();
|
374
|
+
}
|
375
|
+
}
|
376
|
+
});
|
377
|
+
if (widgetData) {
|
378
|
+
this._zone.reveal(widgetData.position);
|
379
|
+
const mode = this._configService.getValue(InlineChatConfigKeys.AccessibleDiffView);
|
380
|
+
if (mode === 'on' || mode === 'auto' && this._accessibilityService.isScreenReaderOptimized()) {
|
381
|
+
this._zone.widget.showAccessibleHunk(this._session, widgetData.hunk);
|
382
|
+
}
|
383
|
+
this._ctxCurrentChangeHasDiff.set(Boolean(widgetData.toggleDiff));
|
384
|
+
}
|
385
|
+
else if (this._hunkData.size > 0) {
|
386
|
+
let oneAccepted = false;
|
387
|
+
for (const hunkData of this._session.hunkData.getInfo()) {
|
388
|
+
if (hunkData.getState() === HunkState.Accepted) {
|
389
|
+
oneAccepted = true;
|
390
|
+
break;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
if (oneAccepted) {
|
394
|
+
this._onDidAccept.fire();
|
395
|
+
}
|
396
|
+
else {
|
397
|
+
this._onDidDiscard.fire();
|
398
|
+
}
|
399
|
+
}
|
400
|
+
return widgetData;
|
401
|
+
};
|
402
|
+
return renderHunks()?.position;
|
403
|
+
}
|
404
|
+
getWholeRangeDecoration() {
|
405
|
+
return [];
|
406
|
+
}
|
407
|
+
async _doApplyChanges(ignoreLocal) {
|
408
|
+
const untitledModels = [];
|
409
|
+
const editor = this._instaService.createInstance(DefaultChatTextEditor);
|
410
|
+
for (const request of this._session.chatModel.getRequests()) {
|
411
|
+
if (!request.response?.response) {
|
412
|
+
continue;
|
413
|
+
}
|
414
|
+
for (const item of request.response.response.value) {
|
415
|
+
if (item.kind !== 'textEditGroup') {
|
416
|
+
continue;
|
417
|
+
}
|
418
|
+
if (ignoreLocal && isEqual(item.uri, this._session.textModelN.uri)) {
|
419
|
+
continue;
|
420
|
+
}
|
421
|
+
await editor.apply(request.response, item, undefined);
|
422
|
+
if (item.uri.scheme === Schemas.untitled) {
|
423
|
+
const untitled = this._textFileService.untitled.get(item.uri);
|
424
|
+
if (untitled) {
|
425
|
+
untitledModels.push(untitled);
|
426
|
+
}
|
427
|
+
}
|
428
|
+
}
|
429
|
+
}
|
430
|
+
for (const untitledModel of untitledModels) {
|
431
|
+
if (!untitledModel.isDisposed()) {
|
432
|
+
await untitledModel.resolve();
|
433
|
+
await untitledModel.save({ reason: SaveReason.EXPLICIT });
|
434
|
+
}
|
435
|
+
}
|
436
|
+
}
|
437
|
+
};
|
438
|
+
LiveStrategy = ( __decorate([
|
439
|
+
( __param(4, IContextKeyService)),
|
440
|
+
( __param(5, IEditorWorkerService)),
|
441
|
+
( __param(6, IAccessibilityService)),
|
442
|
+
( __param(7, IConfigurationService)),
|
443
|
+
( __param(8, IMenuService)),
|
444
|
+
( __param(9, IContextKeyService)),
|
445
|
+
( __param(10, ITextFileService)),
|
446
|
+
( __param(11, IInstantiationService))
|
447
|
+
], LiveStrategy));
|
448
|
+
function changeDecorationsAndViewZones(editor, callback) {
|
449
|
+
editor.changeDecorations(decorationsAccessor => {
|
450
|
+
editor.changeViewZones(viewZoneAccessor => {
|
451
|
+
callback(decorationsAccessor, viewZoneAccessor);
|
452
|
+
});
|
453
|
+
});
|
454
|
+
}
|
455
|
+
|
456
|
+
export { HunkAction, LiveStrategy };
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { ICodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
|
2
|
+
import { Position } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position";
|
3
|
+
import { Range } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range";
|
4
|
+
import { ZoneWidget } from "@codingame/monaco-vscode-api/vscode/vs/editor/contrib/zoneWidget/browser/zoneWidget";
|
5
|
+
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
6
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
7
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
8
|
+
import { IChatWidgetViewOptions } from "@codingame/monaco-vscode-b994942c-360d-5b68-8a33-77d4bde6b714-common/vscode/vs/workbench/contrib/chat/browser/chat";
|
9
|
+
import { IChatWidgetLocationOptions } from "@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/chat/browser/chatWidget";
|
10
|
+
import { INotebookEditor } from "@codingame/monaco-vscode-670aae94-7f88-54d7-90ea-6fcbef423557-common/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser";
|
11
|
+
import { EditorBasedInlineChatWidget } from "@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatWidget";
|
12
|
+
export declare class InlineChatZoneWidget extends ZoneWidget {
|
13
|
+
private readonly _instaService;
|
14
|
+
private _logService;
|
15
|
+
private static readonly _options;
|
16
|
+
readonly widget: EditorBasedInlineChatWidget;
|
17
|
+
private readonly _scrollUp;
|
18
|
+
private readonly _ctxCursorPosition;
|
19
|
+
private _dimension?;
|
20
|
+
private notebookEditor?;
|
21
|
+
constructor(location: IChatWidgetLocationOptions, options: IChatWidgetViewOptions | undefined, editors: {
|
22
|
+
editor: ICodeEditor;
|
23
|
+
notebookEditor?: INotebookEditor;
|
24
|
+
}, _instaService: IInstantiationService, _logService: ILogService, contextKeyService: IContextKeyService);
|
25
|
+
protected _fillContainer(container: HTMLElement): void;
|
26
|
+
protected _doLayout(heightInPixel: number): void;
|
27
|
+
private _computeHeight;
|
28
|
+
protected _getResizeBounds(): {
|
29
|
+
minLines: number;
|
30
|
+
maxLines: number;
|
31
|
+
};
|
32
|
+
protected _onWidth(_widthInPixel: number): void;
|
33
|
+
show(position: Position): void;
|
34
|
+
private _updatePadding;
|
35
|
+
reveal(position: Position): void;
|
36
|
+
updatePositionAndHeight(position: Position): void;
|
37
|
+
private _createZoneAndScrollRestoreFn;
|
38
|
+
protected revealRange(range: Range, isLastLine: boolean): void;
|
39
|
+
hide(): void;
|
40
|
+
}
|