@codingame/monaco-vscode-chat-service-override 2.0.3 → 2.1.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/chat.js +6 -2
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +14 -59
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +11 -16
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +24 -15
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -8
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +106 -115
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +17 -7
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +236 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +210 -0
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditor.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDecorations.js +0 -250
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Queue, raceCancellation } from 'vscode/vscode/vs/base/common/async';
|
|
3
|
+
import { DisposableStore, MutableDisposable, dispose, combinedDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
5
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
6
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
7
|
+
import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService';
|
|
8
|
+
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
9
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
10
|
+
import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
|
11
|
+
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
12
|
+
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
13
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
14
|
+
import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
15
|
+
import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
16
|
+
import { compare } from 'vscode/vscode/vs/base/common/strings';
|
|
17
|
+
import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService';
|
|
18
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
19
|
+
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
20
|
+
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
21
|
+
|
|
22
|
+
let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
23
|
+
constructor(_fileConfigService, _editorGroupService, _textFileService, _editorService, _inlineChatSessionService, _configService, _workingCopyFileService, _logService) {
|
|
24
|
+
this._fileConfigService = _fileConfigService;
|
|
25
|
+
this._editorGroupService = _editorGroupService;
|
|
26
|
+
this._textFileService = _textFileService;
|
|
27
|
+
this._editorService = _editorService;
|
|
28
|
+
this._inlineChatSessionService = _inlineChatSessionService;
|
|
29
|
+
this._configService = _configService;
|
|
30
|
+
this._workingCopyFileService = _workingCopyFileService;
|
|
31
|
+
this._logService = _logService;
|
|
32
|
+
this._store = ( new DisposableStore());
|
|
33
|
+
this._saveParticipant = this._store.add(( new MutableDisposable()));
|
|
34
|
+
this._sessionData = ( new Map());
|
|
35
|
+
this._store.add(Event.any(_inlineChatSessionService.onDidEndSession, _inlineChatSessionService.onDidStashSession)(e => {
|
|
36
|
+
this._sessionData.get(e.session)?.dispose();
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
dispose() {
|
|
40
|
+
this._store.dispose();
|
|
41
|
+
dispose(( this._sessionData.values()));
|
|
42
|
+
}
|
|
43
|
+
markChanged(session) {
|
|
44
|
+
if (!( this._sessionData.has(session))) {
|
|
45
|
+
let uri = session.targetUri;
|
|
46
|
+
if (uri.scheme === Schemas.vscodeNotebookCell) {
|
|
47
|
+
const data = CellUri.parse(uri);
|
|
48
|
+
if (!data) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
uri = data?.notebook;
|
|
52
|
+
}
|
|
53
|
+
if (this._sessionData.size === 0) {
|
|
54
|
+
this._installSaveParticpant();
|
|
55
|
+
}
|
|
56
|
+
const saveConfigOverride = this._fileConfigService.disableAutoSave(uri);
|
|
57
|
+
this._sessionData.set(session, {
|
|
58
|
+
resourceUri: uri,
|
|
59
|
+
groupCandidate: this._editorGroupService.activeGroup,
|
|
60
|
+
session,
|
|
61
|
+
dispose: () => {
|
|
62
|
+
saveConfigOverride.dispose();
|
|
63
|
+
this._sessionData.delete(session);
|
|
64
|
+
if (this._sessionData.size === 0) {
|
|
65
|
+
this._saveParticipant.clear();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
_installSaveParticpant() {
|
|
72
|
+
const queue = ( new Queue());
|
|
73
|
+
const d1 = this._textFileService.files.addSaveParticipant({
|
|
74
|
+
participate: (model, context, progress, token) => {
|
|
75
|
+
return queue.queue(() => this._participate(model.textEditorModel?.uri, context.reason, progress, token));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const d2 = this._workingCopyFileService.addSaveParticipant({
|
|
79
|
+
participate: (workingCopy, env, progress, token) => {
|
|
80
|
+
return queue.queue(() => this._participate(workingCopy.resource, env.reason, progress, token));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
this._saveParticipant.value = combinedDisposable(d1, d2, queue);
|
|
84
|
+
}
|
|
85
|
+
async _participate(uri, reason, progress, token) {
|
|
86
|
+
if (reason !== 1 ) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!this._configService.getValue("inlineChat.acceptedOrDiscardBeforeSave" )) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const sessions = ( new Map());
|
|
93
|
+
for (const [session, data] of this._sessionData) {
|
|
94
|
+
if (uri?.toString() === ( data.resourceUri.toString())) {
|
|
95
|
+
sessions.set(session, data);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (sessions.size === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
progress.report({
|
|
102
|
+
message: sessions.size === 1
|
|
103
|
+
? ( localizeWithPath(
|
|
104
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl',
|
|
105
|
+
'inlineChat',
|
|
106
|
+
"Waiting for Inline Chat changes to be Accepted or Discarded..."
|
|
107
|
+
))
|
|
108
|
+
: ( localizeWithPath(
|
|
109
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl',
|
|
110
|
+
'inlineChat.N',
|
|
111
|
+
"Waiting for Inline Chat changes in {0} editors to be Accepted or Discarded...",
|
|
112
|
+
sessions.size
|
|
113
|
+
))
|
|
114
|
+
});
|
|
115
|
+
const { groups, orphans } = this._getGroupsAndOrphans(( sessions.values()));
|
|
116
|
+
const editorsOpenedAndSessionsEnded = this._openAndWait(groups, token).then(() => {
|
|
117
|
+
if (token.isCancellationRequested) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
return this._openAndWait(( Iterable.map(orphans, s => [this._editorGroupService.activeGroup, s])), token);
|
|
121
|
+
});
|
|
122
|
+
const allSessionsEnded = this._whenSessionsEnded(Iterable.concat(( groups.map(tuple => tuple[1])), orphans), token);
|
|
123
|
+
await Promise.race([allSessionsEnded, editorsOpenedAndSessionsEnded]);
|
|
124
|
+
}
|
|
125
|
+
_getGroupsAndOrphans(sessions) {
|
|
126
|
+
const groupByEditor = ( new Map());
|
|
127
|
+
for (const group of this._editorGroupService.getGroups(1 )) {
|
|
128
|
+
const candidate = group.activeEditorPane?.getControl();
|
|
129
|
+
if (isCodeEditor(candidate)) {
|
|
130
|
+
groupByEditor.set(candidate, group);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const groups = [];
|
|
134
|
+
const orphans = ( new Set());
|
|
135
|
+
for (const data of sessions) {
|
|
136
|
+
const editor = this._inlineChatSessionService.getCodeEditor(data.session);
|
|
137
|
+
const group = groupByEditor.get(editor);
|
|
138
|
+
if (group) {
|
|
139
|
+
groups.push([group, data]);
|
|
140
|
+
}
|
|
141
|
+
else if (this._editorGroupService.groups.includes(data.groupCandidate)) {
|
|
142
|
+
groups.push([data.groupCandidate, data]);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
orphans.add(data);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { groups, orphans };
|
|
149
|
+
}
|
|
150
|
+
async _openAndWait(groups, token) {
|
|
151
|
+
const dataByGroup = ( new Map());
|
|
152
|
+
for (const [group, data] of groups) {
|
|
153
|
+
let array = dataByGroup.get(group);
|
|
154
|
+
if (!array) {
|
|
155
|
+
array = [];
|
|
156
|
+
dataByGroup.set(group, array);
|
|
157
|
+
}
|
|
158
|
+
array.push(data);
|
|
159
|
+
}
|
|
160
|
+
for (const [group, array] of dataByGroup) {
|
|
161
|
+
if (token.isCancellationRequested) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
array.sort((a, b) => compare(( a.session.targetUri.toString()), ( b.session.targetUri.toString())));
|
|
165
|
+
for (const data of array) {
|
|
166
|
+
const input = { resource: data.resourceUri };
|
|
167
|
+
const pane = await this._editorService.openEditor(input, group);
|
|
168
|
+
let editor;
|
|
169
|
+
if (data.session.targetUri.scheme === Schemas.vscodeNotebookCell) {
|
|
170
|
+
const notebookEditor = getNotebookEditorFromEditorPane(pane);
|
|
171
|
+
const uriData = CellUri.parse(data.session.targetUri);
|
|
172
|
+
if (notebookEditor && notebookEditor.hasModel() && uriData) {
|
|
173
|
+
const cell = notebookEditor.getCellByHandle(uriData.handle);
|
|
174
|
+
if (cell) {
|
|
175
|
+
await notebookEditor.revealRangeInCenterIfOutsideViewportAsync(cell, data.session.wholeRange.value);
|
|
176
|
+
}
|
|
177
|
+
const tuple = notebookEditor.codeEditors.find(tuple => tuple[1].getModel()?.uri.toString() === ( data.session.targetUri.toString()));
|
|
178
|
+
editor = tuple?.[1];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
if (isCodeEditor(pane?.getControl())) {
|
|
183
|
+
editor = pane.getControl();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (!editor) {
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
this._inlineChatSessionService.moveSession(data.session, editor);
|
|
190
|
+
InlineChatController.get(editor)?.showSaveHint();
|
|
191
|
+
this._logService.info('WAIT for session to end', editor.getId(), ( data.session.targetUri.toString()));
|
|
192
|
+
await this._whenSessionsEnded(Iterable.single(data), token);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async _whenSessionsEnded(iterable, token) {
|
|
197
|
+
const sessions = ( new Map());
|
|
198
|
+
for (const item of iterable) {
|
|
199
|
+
sessions.set(item.session, item);
|
|
200
|
+
}
|
|
201
|
+
if (sessions.size === 0) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let listener;
|
|
205
|
+
const whenEnded = ( new Promise(resolve => {
|
|
206
|
+
listener = Event.any(this._inlineChatSessionService.onDidEndSession, this._inlineChatSessionService.onDidStashSession)(e => {
|
|
207
|
+
const data = sessions.get(e.session);
|
|
208
|
+
if (data) {
|
|
209
|
+
data.dispose();
|
|
210
|
+
sessions.delete(e.session);
|
|
211
|
+
if (sessions.size === 0) {
|
|
212
|
+
resolve();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}));
|
|
217
|
+
try {
|
|
218
|
+
await raceCancellation(whenEnded, token);
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
listener?.dispose();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
InlineChatSavingServiceImpl = ( __decorate([
|
|
226
|
+
( __param(0, IFilesConfigurationService)),
|
|
227
|
+
( __param(1, IEditorGroupsService)),
|
|
228
|
+
( __param(2, ITextFileService)),
|
|
229
|
+
( __param(3, IEditorService)),
|
|
230
|
+
( __param(4, IInlineChatSessionService)),
|
|
231
|
+
( __param(5, IConfigurationService)),
|
|
232
|
+
( __param(6, IWorkingCopyFileService)),
|
|
233
|
+
( __param(7, ILogService))
|
|
234
|
+
], InlineChatSavingServiceImpl));
|
|
235
|
+
|
|
236
|
+
export { InlineChatSavingServiceImpl };
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
+
import { IInlineChatService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
4
|
+
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
5
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
6
|
+
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
7
|
+
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
8
|
+
import { DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
|
+
import { createTextBufferFactoryFromSnapshot } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
10
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
11
|
+
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
12
|
+
import { raceCancellation } from 'vscode/vscode/vs/base/common/async';
|
|
13
|
+
import { Session, SessionWholeRange, HunkData, StashedSession } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSession';
|
|
14
|
+
import { IEditorWorkerService } from 'vscode/vscode/vs/editor/common/services/editorWorker';
|
|
15
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
16
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
17
|
+
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
18
|
+
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
19
|
+
|
|
20
|
+
let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
|
|
21
|
+
constructor(_inlineChatService, _telemetryService, _modelService, _textModelService, _editorWorkerService, _logService, _instaService, _textFileService) {
|
|
22
|
+
this._inlineChatService = _inlineChatService;
|
|
23
|
+
this._telemetryService = _telemetryService;
|
|
24
|
+
this._modelService = _modelService;
|
|
25
|
+
this._textModelService = _textModelService;
|
|
26
|
+
this._editorWorkerService = _editorWorkerService;
|
|
27
|
+
this._logService = _logService;
|
|
28
|
+
this._instaService = _instaService;
|
|
29
|
+
this._textFileService = _textFileService;
|
|
30
|
+
this._onWillStartSession = ( new Emitter());
|
|
31
|
+
this.onWillStartSession = this._onWillStartSession.event;
|
|
32
|
+
this._onDidMoveSession = ( new Emitter());
|
|
33
|
+
this.onDidMoveSession = this._onDidMoveSession.event;
|
|
34
|
+
this._onDidEndSession = ( new Emitter());
|
|
35
|
+
this.onDidEndSession = this._onDidEndSession.event;
|
|
36
|
+
this._onDidStashSession = ( new Emitter());
|
|
37
|
+
this.onDidStashSession = this._onDidStashSession.event;
|
|
38
|
+
this._sessions = ( new Map());
|
|
39
|
+
this._keyComputers = ( new Map());
|
|
40
|
+
this._recordings = [];
|
|
41
|
+
}
|
|
42
|
+
dispose() {
|
|
43
|
+
this._onWillStartSession.dispose();
|
|
44
|
+
this._onDidEndSession.dispose();
|
|
45
|
+
this._sessions.forEach(x => x.store.dispose());
|
|
46
|
+
this._sessions.clear();
|
|
47
|
+
}
|
|
48
|
+
async createSession(editor, options, token) {
|
|
49
|
+
const provider = Iterable.first(this._inlineChatService.getAllProvider());
|
|
50
|
+
if (!provider) {
|
|
51
|
+
this._logService.trace('[IE] NO provider found');
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
this._onWillStartSession.fire(editor);
|
|
55
|
+
const textModel = editor.getModel();
|
|
56
|
+
const selection = editor.getSelection();
|
|
57
|
+
let rawSession;
|
|
58
|
+
try {
|
|
59
|
+
rawSession = await raceCancellation(Promise.resolve(provider.prepareInlineChatSession(textModel, selection, token)), token);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this._logService.error('[IE] FAILED to prepare session', provider.debugName);
|
|
63
|
+
this._logService.error(error);
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
if (!rawSession) {
|
|
67
|
+
this._logService.trace('[IE] NO session', provider.debugName);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
this._logService.trace('[IE] NEW session', provider.debugName);
|
|
71
|
+
this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${provider.debugName}`);
|
|
72
|
+
const store = ( new DisposableStore());
|
|
73
|
+
const id = generateUuid();
|
|
74
|
+
const targetUri = textModel.uri;
|
|
75
|
+
let textModelN;
|
|
76
|
+
if (options.editMode === "preview" ) {
|
|
77
|
+
textModelN = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.inMemory, query: ( ( new URLSearchParams({ id, 'inline-chat-textModelN': '' })).toString()) }), true));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
store.add((await this._textModelService.createModelReference(textModel.uri)));
|
|
81
|
+
textModelN = textModel;
|
|
82
|
+
}
|
|
83
|
+
const textModel0 = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.inMemory, query: ( ( new URLSearchParams({ id, 'inline-chat-textModel0': '' })).toString()) }), true));
|
|
84
|
+
if (targetUri.scheme === Schemas.untitled) {
|
|
85
|
+
const untitledTextModel = this._textFileService.untitled.get(targetUri);
|
|
86
|
+
if (untitledTextModel) {
|
|
87
|
+
store.add(untitledTextModel.onDidChangeDirty(() => {
|
|
88
|
+
if (!untitledTextModel.isDirty()) {
|
|
89
|
+
this.releaseSession(session);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
let wholeRange = options.wholeRange;
|
|
95
|
+
if (!wholeRange) {
|
|
96
|
+
wholeRange = rawSession.wholeRange ? Range.lift(rawSession.wholeRange) : editor.getSelection();
|
|
97
|
+
}
|
|
98
|
+
const session = ( new Session(
|
|
99
|
+
options.editMode,
|
|
100
|
+
targetUri,
|
|
101
|
+
textModel0,
|
|
102
|
+
textModelN,
|
|
103
|
+
provider,
|
|
104
|
+
rawSession,
|
|
105
|
+
store.add(( new SessionWholeRange(textModelN, wholeRange))),
|
|
106
|
+
store.add(( new HunkData(this._editorWorkerService, textModel0, textModelN)))
|
|
107
|
+
));
|
|
108
|
+
const key = this._key(editor, session.targetUri);
|
|
109
|
+
if (( this._sessions.has(key))) {
|
|
110
|
+
store.dispose();
|
|
111
|
+
throw new Error(`Session already stored for ${key}`);
|
|
112
|
+
}
|
|
113
|
+
this._sessions.set(key, { session, editor, store });
|
|
114
|
+
return session;
|
|
115
|
+
}
|
|
116
|
+
moveSession(session, target) {
|
|
117
|
+
const newKey = this._key(target, session.targetUri);
|
|
118
|
+
const existing = this._sessions.get(newKey);
|
|
119
|
+
if (existing) {
|
|
120
|
+
if (existing.session !== session) {
|
|
121
|
+
throw new Error(`Cannot move session because the target editor already/still has one`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let found = false;
|
|
128
|
+
for (const [oldKey, data] of this._sessions) {
|
|
129
|
+
if (data.session === session) {
|
|
130
|
+
found = true;
|
|
131
|
+
this._sessions.delete(oldKey);
|
|
132
|
+
this._sessions.set(newKey, { ...data, editor: target });
|
|
133
|
+
this._logService.trace(`[IE] did MOVE session for ${data.editor.getId()} to NEW EDITOR ${target.getId()}, ${session.provider.debugName}`);
|
|
134
|
+
this._onDidMoveSession.fire({ session, editor: target });
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (!found) {
|
|
139
|
+
throw new Error(`Cannot move session because it is not stored`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
releaseSession(session) {
|
|
143
|
+
let data;
|
|
144
|
+
for (const [key, value] of this._sessions) {
|
|
145
|
+
if (value.session === session) {
|
|
146
|
+
data = value;
|
|
147
|
+
value.store.dispose();
|
|
148
|
+
this._sessions.delete(key);
|
|
149
|
+
this._logService.trace(`[IE] did RELEASED session for ${value.editor.getId()}, ${session.provider.debugName}`);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (!data) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this._keepRecording(session);
|
|
157
|
+
this._telemetryService.publicLog2('interactiveEditor/session', session.asTelemetryData());
|
|
158
|
+
this._onDidEndSession.fire({ editor: data.editor, session });
|
|
159
|
+
}
|
|
160
|
+
stashSession(session, editor, undoCancelEdits) {
|
|
161
|
+
this._keepRecording(session);
|
|
162
|
+
const result = this._instaService.createInstance(StashedSession, editor, session, undoCancelEdits);
|
|
163
|
+
this._onDidStashSession.fire({ editor, session });
|
|
164
|
+
this._logService.trace(`[IE] did STASH session for ${editor.getId()}, ${session.provider.debugName}`);
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
getCodeEditor(session) {
|
|
168
|
+
for (const [, data] of this._sessions) {
|
|
169
|
+
if (data.session === session) {
|
|
170
|
+
return data.editor;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
throw new Error('session not found');
|
|
174
|
+
}
|
|
175
|
+
getSession(editor, uri) {
|
|
176
|
+
const key = this._key(editor, uri);
|
|
177
|
+
return this._sessions.get(key)?.session;
|
|
178
|
+
}
|
|
179
|
+
_key(editor, uri) {
|
|
180
|
+
const item = this._keyComputers.get(uri.scheme);
|
|
181
|
+
return item
|
|
182
|
+
? item.getComparisonKey(editor, uri)
|
|
183
|
+
: `${editor.getId()}@${( uri.toString())}`;
|
|
184
|
+
}
|
|
185
|
+
registerSessionKeyComputer(scheme, value) {
|
|
186
|
+
this._keyComputers.set(scheme, value);
|
|
187
|
+
return toDisposable(() => this._keyComputers.delete(scheme));
|
|
188
|
+
}
|
|
189
|
+
_keepRecording(session) {
|
|
190
|
+
const newLen = this._recordings.unshift(session.asRecording());
|
|
191
|
+
if (newLen > 5) {
|
|
192
|
+
this._recordings.pop();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
recordings() {
|
|
196
|
+
return this._recordings;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
InlineChatSessionServiceImpl = ( __decorate([
|
|
200
|
+
( __param(0, IInlineChatService)),
|
|
201
|
+
( __param(1, ITelemetryService)),
|
|
202
|
+
( __param(2, IModelService)),
|
|
203
|
+
( __param(3, ITextModelService)),
|
|
204
|
+
( __param(4, IEditorWorkerService)),
|
|
205
|
+
( __param(5, ILogService)),
|
|
206
|
+
( __param(6, IInstantiationService)),
|
|
207
|
+
( __param(7, ITextFileService))
|
|
208
|
+
], InlineChatSessionServiceImpl));
|
|
209
|
+
|
|
210
|
+
export { InlineChatSessionServiceImpl };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
2
|
-
|
|
3
|
-
export { n as default };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
|
|
2
|
-
|
|
3
|
-
var css = ".show-file-icons .chat-editor-label.file-icon:before,.vs .show-file-icons .chat-editor-label.file-icon:before{content:\"\\EAC7\";font-family:codicon;font-size:16px}";
|
|
4
|
-
n(css,{});
|
|
5
|
-
|
|
6
|
-
export { css, css as default };
|