@codingame/monaco-vscode-chat-service-override 3.2.3 → 4.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.
Files changed (32) hide show
  1. package/chat.js +16 -14
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js +16 -0
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/external/vscode-marked/lib/marked.esm.js +0 -2200
  6. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +0 -17
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +0 -115
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +0 -501
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +0 -82
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +0 -77
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +0 -110
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +0 -171
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +0 -271
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +0 -299
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +0 -60
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatContributionServiceImpl.js +0 -179
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +0 -87
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +0 -271
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +0 -74
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +0 -174
  22. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +0 -26
  23. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +0 -580
  24. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +0 -36
  25. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +0 -601
  26. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +0 -43
  27. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +0 -41
  28. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +0 -814
  29. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +0 -72
  30. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +0 -236
  31. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +0 -223
  32. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +0 -33
@@ -1,72 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { illegalState } from 'vscode/vscode/vs/base/common/errors';
3
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
5
- import { isEqual } from 'vscode/vscode/vs/base/common/resources';
6
- import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
7
- import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService';
8
- import { INotebookEditorService } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService';
9
- import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
10
-
11
- let InlineChatNotebookContribution = class InlineChatNotebookContribution {
12
- constructor(sessionService, notebookEditorService) {
13
- this._store = ( new DisposableStore());
14
- this._store.add(sessionService.registerSessionKeyComputer(Schemas.vscodeNotebookCell, {
15
- getComparisonKey: (editor, uri) => {
16
- const data = CellUri.parse(uri);
17
- if (!data) {
18
- throw illegalState('Expected notebook cell uri');
19
- }
20
- let fallback;
21
- for (const notebookEditor of notebookEditorService.listNotebookEditors()) {
22
- if (notebookEditor.hasModel() && isEqual(notebookEditor.textModel.uri, data.notebook)) {
23
- const candidate = `<notebook>${notebookEditor.getId()}#${uri}`;
24
- if (!fallback) {
25
- fallback = candidate;
26
- }
27
- if (notebookEditor.codeEditors.find((tuple) => tuple[1] === editor)) {
28
- return candidate;
29
- }
30
- }
31
- }
32
- if (fallback) {
33
- return fallback;
34
- }
35
- throw illegalState('Expected notebook editor');
36
- }
37
- }));
38
- this._store.add(sessionService.onWillStartSession(newSessionEditor => {
39
- const candidate = CellUri.parse(newSessionEditor.getModel().uri);
40
- if (!candidate) {
41
- return;
42
- }
43
- for (const notebookEditor of notebookEditorService.listNotebookEditors()) {
44
- if (isEqual(notebookEditor.textModel?.uri, candidate.notebook)) {
45
- let found = false;
46
- const editors = [];
47
- for (const [, codeEditor] of notebookEditor.codeEditors) {
48
- editors.push(codeEditor);
49
- found = codeEditor === newSessionEditor || found;
50
- }
51
- if (found) {
52
- for (const editor of editors) {
53
- if (editor !== newSessionEditor) {
54
- InlineChatController.get(editor)?.finishExistingSession();
55
- }
56
- }
57
- break;
58
- }
59
- }
60
- }
61
- }));
62
- }
63
- dispose() {
64
- this._store.dispose();
65
- }
66
- };
67
- InlineChatNotebookContribution = ( __decorate([
68
- ( __param(0, IInlineChatSessionService)),
69
- ( __param(1, INotebookEditorService))
70
- ], InlineChatNotebookContribution));
71
-
72
- export { InlineChatNotebookContribution };
@@ -1,236 +0,0 @@
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, ctx, progress, token) => {
75
- return queue.queue(() => this._participate(ctx.savedFrom ?? model.textEditorModel?.uri, ctx.reason, progress, token));
76
- }
77
- });
78
- const d2 = this._workingCopyFileService.addSaveParticipant({
79
- participate: (workingCopy, ctx, progress, token) => {
80
- return queue.queue(() => this._participate(ctx.savedFrom ?? workingCopy.resource, ctx.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 };
@@ -1,223 +0,0 @@
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 { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
19
- import { UntitledTextEditorInput } from 'vscode/vscode/vs/workbench/services/untitled/common/untitledTextEditorInput';
20
- import { DEFAULT_EDITOR_ASSOCIATION } from 'vscode/vscode/vs/workbench/common/editor';
21
-
22
- let InlineChatSessionServiceImpl = class InlineChatSessionServiceImpl {
23
- constructor(_inlineChatService, _telemetryService, _modelService, _textModelService, _editorWorkerService, _logService, _instaService, _editorService) {
24
- this._inlineChatService = _inlineChatService;
25
- this._telemetryService = _telemetryService;
26
- this._modelService = _modelService;
27
- this._textModelService = _textModelService;
28
- this._editorWorkerService = _editorWorkerService;
29
- this._logService = _logService;
30
- this._instaService = _instaService;
31
- this._editorService = _editorService;
32
- this._onWillStartSession = ( new Emitter());
33
- this.onWillStartSession = this._onWillStartSession.event;
34
- this._onDidMoveSession = ( new Emitter());
35
- this.onDidMoveSession = this._onDidMoveSession.event;
36
- this._onDidEndSession = ( new Emitter());
37
- this.onDidEndSession = this._onDidEndSession.event;
38
- this._onDidStashSession = ( new Emitter());
39
- this.onDidStashSession = this._onDidStashSession.event;
40
- this._sessions = ( new Map());
41
- this._keyComputers = ( new Map());
42
- this._recordings = [];
43
- }
44
- dispose() {
45
- this._onWillStartSession.dispose();
46
- this._onDidEndSession.dispose();
47
- this._sessions.forEach(x => x.store.dispose());
48
- this._sessions.clear();
49
- }
50
- async createSession(editor, options, token) {
51
- const provider = Iterable.first(this._inlineChatService.getAllProvider());
52
- if (!provider) {
53
- this._logService.trace('[IE] NO provider found');
54
- return undefined;
55
- }
56
- this._onWillStartSession.fire(editor);
57
- const textModel = editor.getModel();
58
- const selection = editor.getSelection();
59
- let rawSession;
60
- try {
61
- rawSession = await raceCancellation(Promise.resolve(provider.prepareInlineChatSession(textModel, selection, token)), token);
62
- }
63
- catch (error) {
64
- this._logService.error('[IE] FAILED to prepare session', provider.debugName);
65
- this._logService.error(error);
66
- return undefined;
67
- }
68
- if (!rawSession) {
69
- this._logService.trace('[IE] NO session', provider.debugName);
70
- return undefined;
71
- }
72
- this._logService.trace('[IE] NEW session', provider.debugName);
73
- this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${provider.debugName}`);
74
- const store = ( new DisposableStore());
75
- store.add(this._inlineChatService.onDidChangeProviders(e => {
76
- if (e.removed === provider) {
77
- this._logService.trace(`[IE] provider GONE for ${editor.getId()}, ${provider.debugName}`);
78
- this._releaseSession(session, true);
79
- }
80
- }));
81
- const id = generateUuid();
82
- const targetUri = textModel.uri;
83
- let textModelN;
84
- if (options.editMode === "preview" ) {
85
- textModelN = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.vscode, authority: 'inline-chat', path: '', query: ( ( new URLSearchParams({ id, 'textModelN': '' })).toString()) })));
86
- }
87
- else {
88
- store.add((await this._textModelService.createModelReference(textModel.uri)));
89
- textModelN = textModel;
90
- }
91
- const textModel0 = store.add(this._modelService.createModel(createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, targetUri.with({ scheme: Schemas.vscode, authority: 'inline-chat', path: '', query: ( ( new URLSearchParams({ id, 'textModel0': '' })).toString()) }), true));
92
- if (targetUri.scheme === Schemas.untitled) {
93
- store.add(this._editorService.onDidCloseEditor(() => {
94
- if (!this._editorService.isOpened({ resource: targetUri, typeId: UntitledTextEditorInput.ID, editorId: DEFAULT_EDITOR_ASSOCIATION.id })) {
95
- this._releaseSession(session, true);
96
- }
97
- }));
98
- }
99
- let wholeRange = options.wholeRange;
100
- if (!wholeRange) {
101
- wholeRange = rawSession.wholeRange ? Range.lift(rawSession.wholeRange) : editor.getSelection();
102
- }
103
- if (token.isCancellationRequested) {
104
- store.dispose();
105
- return undefined;
106
- }
107
- const session = ( new Session(
108
- options.editMode,
109
- targetUri,
110
- textModel0,
111
- textModelN,
112
- provider,
113
- rawSession,
114
- store.add(( new SessionWholeRange(textModelN, wholeRange))),
115
- store.add(( new HunkData(this._editorWorkerService, textModel0, textModelN)))
116
- ));
117
- const key = this._key(editor, session.targetUri);
118
- if (( this._sessions.has(key))) {
119
- store.dispose();
120
- throw new Error(`Session already stored for ${key}`);
121
- }
122
- this._sessions.set(key, { session, editor, store });
123
- return session;
124
- }
125
- moveSession(session, target) {
126
- const newKey = this._key(target, session.targetUri);
127
- const existing = this._sessions.get(newKey);
128
- if (existing) {
129
- if (existing.session !== session) {
130
- throw new Error(`Cannot move session because the target editor already/still has one`);
131
- }
132
- else {
133
- return;
134
- }
135
- }
136
- let found = false;
137
- for (const [oldKey, data] of this._sessions) {
138
- if (data.session === session) {
139
- found = true;
140
- this._sessions.delete(oldKey);
141
- this._sessions.set(newKey, { ...data, editor: target });
142
- this._logService.trace(`[IE] did MOVE session for ${data.editor.getId()} to NEW EDITOR ${target.getId()}, ${session.provider.debugName}`);
143
- this._onDidMoveSession.fire({ session, editor: target });
144
- break;
145
- }
146
- }
147
- if (!found) {
148
- throw new Error(`Cannot move session because it is not stored`);
149
- }
150
- }
151
- releaseSession(session) {
152
- this._releaseSession(session, false);
153
- }
154
- _releaseSession(session, byServer) {
155
- let tuple;
156
- for (const candidate of this._sessions) {
157
- if (candidate[1].session === session) {
158
- tuple = candidate;
159
- break;
160
- }
161
- }
162
- if (!tuple) {
163
- return;
164
- }
165
- this._keepRecording(session);
166
- this._telemetryService.publicLog2('interactiveEditor/session', session.asTelemetryData());
167
- const [key, value] = tuple;
168
- this._sessions.delete(key);
169
- this._logService.trace(`[IE] did RELEASED session for ${value.editor.getId()}, ${session.provider.debugName}`);
170
- this._onDidEndSession.fire({ editor: value.editor, session, endedByExternalCause: byServer });
171
- value.store.dispose();
172
- }
173
- stashSession(session, editor, undoCancelEdits) {
174
- this._keepRecording(session);
175
- const result = this._instaService.createInstance(StashedSession, editor, session, undoCancelEdits);
176
- this._onDidStashSession.fire({ editor, session });
177
- this._logService.trace(`[IE] did STASH session for ${editor.getId()}, ${session.provider.debugName}`);
178
- return result;
179
- }
180
- getCodeEditor(session) {
181
- for (const [, data] of this._sessions) {
182
- if (data.session === session) {
183
- return data.editor;
184
- }
185
- }
186
- throw new Error('session not found');
187
- }
188
- getSession(editor, uri) {
189
- const key = this._key(editor, uri);
190
- return this._sessions.get(key)?.session;
191
- }
192
- _key(editor, uri) {
193
- const item = this._keyComputers.get(uri.scheme);
194
- return item
195
- ? item.getComparisonKey(editor, uri)
196
- : `${editor.getId()}@${( uri.toString())}`;
197
- }
198
- registerSessionKeyComputer(scheme, value) {
199
- this._keyComputers.set(scheme, value);
200
- return toDisposable(() => this._keyComputers.delete(scheme));
201
- }
202
- _keepRecording(session) {
203
- const newLen = this._recordings.unshift(session.asRecording());
204
- if (newLen > 5) {
205
- this._recordings.pop();
206
- }
207
- }
208
- recordings() {
209
- return this._recordings;
210
- }
211
- };
212
- InlineChatSessionServiceImpl = ( __decorate([
213
- ( __param(0, IInlineChatService)),
214
- ( __param(1, ITelemetryService)),
215
- ( __param(2, IModelService)),
216
- ( __param(3, ITextModelService)),
217
- ( __param(4, IEditorWorkerService)),
218
- ( __param(5, ILogService)),
219
- ( __param(6, IInstantiationService)),
220
- ( __param(7, IEditorService))
221
- ], InlineChatSessionServiceImpl));
222
-
223
- export { InlineChatSessionServiceImpl };
@@ -1,33 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
3
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
- import { LinkedList } from 'vscode/vscode/vs/base/common/linkedList';
5
- import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
6
- import { CTX_INLINE_CHAT_HAS_PROVIDER } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
7
-
8
- let InlineChatServiceImpl = class InlineChatServiceImpl {
9
- constructor(contextKeyService) {
10
- this._onDidChangeProviders = ( new Emitter());
11
- this._entries = ( new LinkedList());
12
- this.onDidChangeProviders = this._onDidChangeProviders.event;
13
- this._ctxHasProvider = CTX_INLINE_CHAT_HAS_PROVIDER.bindTo(contextKeyService);
14
- }
15
- addProvider(provider) {
16
- const rm = this._entries.push(provider);
17
- this._ctxHasProvider.set(true);
18
- this._onDidChangeProviders.fire({ added: provider });
19
- return toDisposable(() => {
20
- rm();
21
- this._ctxHasProvider.set(this._entries.size > 0);
22
- this._onDidChangeProviders.fire({ removed: provider });
23
- });
24
- }
25
- getAllProvider() {
26
- return [...this._entries].reverse();
27
- }
28
- };
29
- InlineChatServiceImpl = ( __decorate([
30
- ( __param(0, IContextKeyService))
31
- ], InlineChatServiceImpl));
32
-
33
- export { InlineChatServiceImpl };