@codingame/monaco-vscode-notebook-service-override 13.1.7 → 14.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/index.js +3 -3
- package/package.json +29 -28
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +8 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +25 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookCellDecorators.d.ts +60 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookCellDecorators.js +536 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatActionsOverlay.js +310 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditController.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditController.js +182 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.d.ts +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.js +42 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.d.ts +23 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.d.ts +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.js +425 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizerService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizerService.js +0 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +9 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +11 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +9 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +15 -15
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.d.ts +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +310 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +35 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +14 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +32 -32
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +29 -26
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +25 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +25 -25
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +19 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +8 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +14 -14
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +21 -21
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +92 -74
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +11 -11
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +33 -33
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.d.ts +1 -1
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +16 -13
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +5 -3
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.d.ts +2 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +2 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.d.ts +9 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +5 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable, toDisposable, MutableDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { getNotebookEditorFromEditorPane, CellEditState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
5
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
+
import { MenuWorkbenchToolBar, HiddenItemStrategy } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/toolbar';
|
|
7
|
+
import { MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
8
|
+
import { ActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionViewItems';
|
|
9
|
+
import { ActionRunner } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
|
|
10
|
+
import { $ } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
11
|
+
import { IChatEditingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
|
|
12
|
+
import { ACTIVE_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
|
|
13
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
14
|
+
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
15
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
16
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
17
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
18
|
+
import { autorunWithStore, autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
19
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
|
20
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
21
|
+
import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
22
|
+
import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
23
|
+
import { navigationBearingFakeActionId, AcceptAction, RejectAction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatEditorActions';
|
|
24
|
+
|
|
25
|
+
let NotebookChatActionsOverlayController = class NotebookChatActionsOverlayController extends Disposable {
|
|
26
|
+
constructor(notebookEditor, cellDiffInfo, deletedCellDecorator, _chatEditingService, instantiationService) {
|
|
27
|
+
super();
|
|
28
|
+
this.notebookEditor = notebookEditor;
|
|
29
|
+
this._chatEditingService = _chatEditingService;
|
|
30
|
+
const notebookModel = observableFromEvent(this.notebookEditor.onDidChangeModel, e => e);
|
|
31
|
+
this._register(autorunWithStore((r, store) => {
|
|
32
|
+
const session = this._chatEditingService.currentEditingSessionObs.read(r);
|
|
33
|
+
const model = notebookModel.read(r);
|
|
34
|
+
if (!model || !session) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const entries = session.entries.read(r);
|
|
38
|
+
const idx = entries.findIndex(e => isEqual(e.modifiedURI, model.uri));
|
|
39
|
+
if (idx >= 0) {
|
|
40
|
+
const entry = entries[idx];
|
|
41
|
+
const nextEntry = entries[(idx + 1) % entries.length];
|
|
42
|
+
const previousEntry = entries[(idx - 1 + entries.length) % entries.length];
|
|
43
|
+
store.add(instantiationService.createInstance(NotebookChatActionsOverlay, notebookEditor, entry, cellDiffInfo, nextEntry, previousEntry, deletedCellDecorator));
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
NotebookChatActionsOverlayController = ( __decorate([
|
|
49
|
+
( __param(3, IChatEditingService)),
|
|
50
|
+
( __param(4, IInstantiationService))
|
|
51
|
+
], NotebookChatActionsOverlayController));
|
|
52
|
+
let NotebookChatActionsOverlay = class NotebookChatActionsOverlay extends Disposable {
|
|
53
|
+
constructor(notebookEditor, entry, cellDiffInfo, nextEntry, previousEntry, deletedCellDecorator, _editorService, instaService) {
|
|
54
|
+
super();
|
|
55
|
+
this.notebookEditor = notebookEditor;
|
|
56
|
+
this._editorService = _editorService;
|
|
57
|
+
this.focusedDiff = observableValue('focusedDiff', undefined);
|
|
58
|
+
this.added = false;
|
|
59
|
+
this._register(notebookEditor.onDidBlurWidget(() => {
|
|
60
|
+
if (getNotebookEditorFromEditorPane(_editorService.activeEditorPane) !== notebookEditor) {
|
|
61
|
+
this.focusedDiff.set(undefined, undefined);
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
this._register(notebookEditor.onDidChangeActiveEditor(e => {
|
|
65
|
+
if (e !== notebookEditor) {
|
|
66
|
+
this.focusedDiff.set(undefined, undefined);
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
this.toolbarNode = $('div');
|
|
70
|
+
this.toolbarNode.classList.add('notebook-chat-editor-overlay-widget');
|
|
71
|
+
this._register(toDisposable(() => this.hide()));
|
|
72
|
+
this._register(autorun(r => {
|
|
73
|
+
const diffs = cellDiffInfo.read(r);
|
|
74
|
+
if (diffs?.some(d => d.type !== 'unchanged')) {
|
|
75
|
+
this.show();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.hide();
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
const focusedDiff = this.focusedDiff;
|
|
82
|
+
const _toolbar = instaService.createInstance(MenuWorkbenchToolBar, this.toolbarNode, MenuId.ChatEditingEditorContent, {
|
|
83
|
+
telemetrySource: 'chatEditor.overlayToolbar',
|
|
84
|
+
hiddenItemStrategy: HiddenItemStrategy.Ignore,
|
|
85
|
+
toolbarOptions: {
|
|
86
|
+
primaryGroup: () => true,
|
|
87
|
+
useSeparatorsInPrimaryActions: true
|
|
88
|
+
},
|
|
89
|
+
menuOptions: { renderShortTitle: true },
|
|
90
|
+
actionViewItemProvider: (action, options) => {
|
|
91
|
+
const that = this;
|
|
92
|
+
if (action.id === navigationBearingFakeActionId) {
|
|
93
|
+
return new (class extends ActionViewItem {
|
|
94
|
+
constructor() {
|
|
95
|
+
super(undefined, action, { ...options, icon: false, label: false, keybindingNotRenderedWithLabel: true });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (action.id === AcceptAction.ID || action.id === RejectAction.ID) {
|
|
100
|
+
return new (class extends ActionViewItem {
|
|
101
|
+
constructor() {
|
|
102
|
+
super(undefined, action, { ...options, icon: false, label: true, keybindingNotRenderedWithLabel: true });
|
|
103
|
+
this._reveal = this._store.add(( new MutableDisposable()));
|
|
104
|
+
}
|
|
105
|
+
set actionRunner(actionRunner) {
|
|
106
|
+
super.actionRunner = actionRunner;
|
|
107
|
+
const store = ( new DisposableStore());
|
|
108
|
+
store.add(actionRunner.onWillRun(_e => {
|
|
109
|
+
notebookEditor.focus();
|
|
110
|
+
}));
|
|
111
|
+
store.add(actionRunner.onDidRun(e => {
|
|
112
|
+
if (e.action !== this.action) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (entry === nextEntry) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const change = nextEntry.diffInfo.get().changes.at(0);
|
|
119
|
+
return that._editorService.openEditor({
|
|
120
|
+
resource: nextEntry.modifiedURI,
|
|
121
|
+
options: {
|
|
122
|
+
selection: change && Range.fromPositions({ lineNumber: change.original.startLineNumber, column: 1 }),
|
|
123
|
+
revealIfOpened: false,
|
|
124
|
+
revealIfVisible: false,
|
|
125
|
+
}
|
|
126
|
+
}, ACTIVE_GROUP);
|
|
127
|
+
}));
|
|
128
|
+
this._reveal.value = store;
|
|
129
|
+
}
|
|
130
|
+
get actionRunner() {
|
|
131
|
+
return super.actionRunner;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (action.id === 'chatEditor.action.navigateNext' || action.id === 'chatEditor.action.navigatePrevious') {
|
|
136
|
+
return new (class extends ActionViewItem {
|
|
137
|
+
constructor() {
|
|
138
|
+
super(undefined, action, { ...options, icon: true, label: false, keybindingNotRenderedWithLabel: true });
|
|
139
|
+
}
|
|
140
|
+
set actionRunner(_) {
|
|
141
|
+
const next = action.id === 'chatEditor.action.navigateNext' ? nextEntry : previousEntry;
|
|
142
|
+
const direction = action.id === 'chatEditor.action.navigateNext' ? 'next' : 'previous';
|
|
143
|
+
super.actionRunner = ( new NextPreviousChangeActionRunner(
|
|
144
|
+
notebookEditor,
|
|
145
|
+
cellDiffInfo,
|
|
146
|
+
entry,
|
|
147
|
+
next,
|
|
148
|
+
direction,
|
|
149
|
+
_editorService,
|
|
150
|
+
deletedCellDecorator,
|
|
151
|
+
focusedDiff
|
|
152
|
+
));
|
|
153
|
+
}
|
|
154
|
+
get actionRunner() {
|
|
155
|
+
return super.actionRunner;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
this._register(_toolbar);
|
|
163
|
+
}
|
|
164
|
+
show() {
|
|
165
|
+
if (!this.added) {
|
|
166
|
+
this.notebookEditor.getDomNode().appendChild(this.toolbarNode);
|
|
167
|
+
this.added = true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
hide() {
|
|
171
|
+
if (this.added) {
|
|
172
|
+
this.notebookEditor.getDomNode().removeChild(this.toolbarNode);
|
|
173
|
+
this.added = false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
NotebookChatActionsOverlay = ( __decorate([
|
|
178
|
+
( __param(6, IEditorService)),
|
|
179
|
+
( __param(7, IInstantiationService))
|
|
180
|
+
], NotebookChatActionsOverlay));
|
|
181
|
+
class NextPreviousChangeActionRunner extends ActionRunner {
|
|
182
|
+
constructor(notebookEditor, cellDiffInfo, entry, next, direction, editorService, deletedCellDecorator, focusedDiff) {
|
|
183
|
+
super();
|
|
184
|
+
this.notebookEditor = notebookEditor;
|
|
185
|
+
this.cellDiffInfo = cellDiffInfo;
|
|
186
|
+
this.entry = entry;
|
|
187
|
+
this.next = next;
|
|
188
|
+
this.direction = direction;
|
|
189
|
+
this.editorService = editorService;
|
|
190
|
+
this.deletedCellDecorator = deletedCellDecorator;
|
|
191
|
+
this.focusedDiff = focusedDiff;
|
|
192
|
+
}
|
|
193
|
+
async runAction(_action, _context) {
|
|
194
|
+
const viewModel = this.notebookEditor.getViewModel();
|
|
195
|
+
const activeCell = this.notebookEditor.activeCellAndCodeEditor;
|
|
196
|
+
const cellDiff = this.cellDiffInfo.read(undefined);
|
|
197
|
+
if (!viewModel || !cellDiff?.length || (!activeCell && this.focusedDiff.read(undefined))) {
|
|
198
|
+
return this.goToNextEntry();
|
|
199
|
+
}
|
|
200
|
+
const nextDiff = this.getNextCellDiff(cellDiff, viewModel);
|
|
201
|
+
if (nextDiff && (await this.focusDiff(nextDiff, viewModel))) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
return this.goToNextEntry();
|
|
205
|
+
}
|
|
206
|
+
async focusDiff(diff, viewModel) {
|
|
207
|
+
if (diff.type === 'delete') {
|
|
208
|
+
const top = this.deletedCellDecorator.getTop(diff.originalCellIndex);
|
|
209
|
+
if (typeof top === 'number') {
|
|
210
|
+
this.focusedDiff.set(diff, undefined);
|
|
211
|
+
this.notebookEditor.setScrollTop(top);
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const index = diff.modifiedCellIndex;
|
|
217
|
+
this.focusedDiff.set(diff, undefined);
|
|
218
|
+
await this.notebookEditor.focusNotebookCell(viewModel.viewCells[index], 'container');
|
|
219
|
+
this.notebookEditor.revealInViewAtTop(viewModel.viewCells[index]);
|
|
220
|
+
viewModel.viewCells[index].updateEditState(CellEditState.Editing, 'chatEdit');
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
getNextCellDiff(cellDiffInfo, viewModel) {
|
|
226
|
+
const activeCell = this.notebookEditor.activeCellAndCodeEditor;
|
|
227
|
+
const currentCellIndex = activeCell ? viewModel.viewCells.findIndex(c => c.handle === activeCell[0].handle) : (this.direction === 'next' ? 0 : viewModel.viewCells.length - 1);
|
|
228
|
+
if (this.focusedDiff.read(undefined)) {
|
|
229
|
+
const changes = cellDiffInfo.filter(d => d.type !== 'unchanged');
|
|
230
|
+
const idx = changes.findIndex(d => d === this.focusedDiff.read(undefined));
|
|
231
|
+
if (idx >= 0) {
|
|
232
|
+
const next = this.direction === 'next' ? idx + 1 : idx - 1;
|
|
233
|
+
if (next >= 0 && next < changes.length) {
|
|
234
|
+
return changes[next];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else if (this.direction === 'next') {
|
|
239
|
+
let currentIndex = 0;
|
|
240
|
+
let next;
|
|
241
|
+
cellDiffInfo
|
|
242
|
+
.forEach((d, i) => {
|
|
243
|
+
if (next) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (d.type === 'insert' || d.type === 'modified') {
|
|
247
|
+
if (d.modifiedCellIndex > currentCellIndex) {
|
|
248
|
+
next = d;
|
|
249
|
+
}
|
|
250
|
+
currentIndex = d.modifiedCellIndex;
|
|
251
|
+
}
|
|
252
|
+
else if (d.type === 'unchanged') {
|
|
253
|
+
currentIndex = d.modifiedCellIndex;
|
|
254
|
+
}
|
|
255
|
+
else if (currentIndex >= currentCellIndex) {
|
|
256
|
+
next = d;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
if (next) {
|
|
260
|
+
return next;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
let currentIndex = 0;
|
|
265
|
+
let previous;
|
|
266
|
+
cellDiffInfo
|
|
267
|
+
.forEach((d, i) => {
|
|
268
|
+
if (d.type === 'insert' || d.type === 'modified') {
|
|
269
|
+
if (d.modifiedCellIndex < currentCellIndex) {
|
|
270
|
+
previous = d;
|
|
271
|
+
}
|
|
272
|
+
currentIndex = d.modifiedCellIndex;
|
|
273
|
+
}
|
|
274
|
+
else if (d.type === 'unchanged') {
|
|
275
|
+
currentIndex = d.modifiedCellIndex;
|
|
276
|
+
}
|
|
277
|
+
else if (currentIndex <= currentCellIndex) {
|
|
278
|
+
previous = d;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
if (previous) {
|
|
282
|
+
return previous;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (this.canGoToNextEntry()) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
return this.direction === 'next' ? cellDiffInfo[0] : cellDiffInfo[cellDiffInfo.length - 1];
|
|
289
|
+
}
|
|
290
|
+
canGoToNextEntry() {
|
|
291
|
+
return this.entry !== this.next;
|
|
292
|
+
}
|
|
293
|
+
async goToNextEntry() {
|
|
294
|
+
if (!this.canGoToNextEntry()) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const change = this.next.diffInfo.get().changes.at(0);
|
|
298
|
+
this.focusedDiff.set(undefined, undefined);
|
|
299
|
+
await this.editorService.openEditor({
|
|
300
|
+
resource: this.next.modifiedURI,
|
|
301
|
+
options: {
|
|
302
|
+
selection: change && Range.fromPositions({ lineNumber: change.original.startLineNumber, column: 1 }),
|
|
303
|
+
revealIfOpened: false,
|
|
304
|
+
revealIfVisible: false,
|
|
305
|
+
}
|
|
306
|
+
}, ACTIVE_GROUP);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export { NotebookChatActionsOverlay, NotebookChatActionsOverlayController };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { INotebookEditor, INotebookEditorContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser";
|
|
3
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
4
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
5
|
+
export declare class NotebookChatEditorControllerContrib extends Disposable implements INotebookEditorContribution {
|
|
6
|
+
static readonly ID: string;
|
|
7
|
+
readonly _serviceBrand: undefined;
|
|
8
|
+
constructor(notebookEditor: INotebookEditor, instantiationService: IInstantiationService, configurationService: IConfigurationService);
|
|
9
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable, dispose, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
5
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
6
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
7
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
8
|
+
import { derived, derivedWithStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
|
9
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
10
|
+
import { observableFromEvent, debouncedObservable2 } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
11
|
+
import { WorkingSetEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
|
|
12
|
+
import { IChatEditingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
|
|
13
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
14
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
15
|
+
import { NotebookDeletedCellDecorator, NotebookInsertedCellDecorator, NotebookCellDiffDecorator } from './notebookCellDecorators.js';
|
|
16
|
+
import './notebookSynchronizer.js';
|
|
17
|
+
import { INotebookModelSynchronizerFactory } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookSynchronizer.service';
|
|
18
|
+
import './notebookOriginalModelRefFactory.js';
|
|
19
|
+
import { INotebookOriginalModelReferenceFactory } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.service';
|
|
20
|
+
import { NotebookChatActionsOverlayController } from './notebookChatActionsOverlay.js';
|
|
21
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
22
|
+
import { registerNotebookContribution } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
23
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
24
|
+
import './notebookOriginalCellModelFactory.js';
|
|
25
|
+
import { ctxNotebookHasEditorModification } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookChatEditContext';
|
|
26
|
+
|
|
27
|
+
let NotebookChatEditorControllerContrib = class NotebookChatEditorControllerContrib extends Disposable {
|
|
28
|
+
static { this.ID = 'workbench.notebook.chatEditorController'; }
|
|
29
|
+
constructor(notebookEditor, instantiationService, configurationService) {
|
|
30
|
+
super();
|
|
31
|
+
this._register(instantiationService.createInstance(NotebookChatEditorController, notebookEditor));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
NotebookChatEditorControllerContrib = ( __decorate([
|
|
35
|
+
( __param(1, IInstantiationService)),
|
|
36
|
+
( __param(2, IConfigurationService))
|
|
37
|
+
], NotebookChatEditorControllerContrib));
|
|
38
|
+
let NotebookChatEditorController = class NotebookChatEditorController extends Disposable {
|
|
39
|
+
constructor(notebookEditor, _chatEditingService, originalModelRefFactory, synchronizerFactory, instantiationService, contextKeyService) {
|
|
40
|
+
super();
|
|
41
|
+
this.notebookEditor = notebookEditor;
|
|
42
|
+
this._chatEditingService = _chatEditingService;
|
|
43
|
+
this.originalModelRefFactory = originalModelRefFactory;
|
|
44
|
+
this.synchronizerFactory = synchronizerFactory;
|
|
45
|
+
this.instantiationService = instantiationService;
|
|
46
|
+
this._ctxHasEditorModification = ctxNotebookHasEditorModification.bindTo(contextKeyService);
|
|
47
|
+
this.deletedCellDecorator = this._register(instantiationService.createInstance(NotebookDeletedCellDecorator, notebookEditor));
|
|
48
|
+
this.insertedCellDecorator = this._register(instantiationService.createInstance(NotebookInsertedCellDecorator, notebookEditor));
|
|
49
|
+
const notebookModel = observableFromEvent(this.notebookEditor.onDidChangeModel, e => e);
|
|
50
|
+
const originalModel = observableValue('originalModel', undefined);
|
|
51
|
+
const readyToRenderViewzones = observableValue('viewModelAttached', false);
|
|
52
|
+
this._register(Event.once(this.notebookEditor.onDidAttachViewModel)(() => readyToRenderViewzones.set(true, undefined)));
|
|
53
|
+
const onDidChangeVisibleRanges = debouncedObservable2(observableFromEvent(this.notebookEditor.onDidChangeVisibleRanges, () => this.notebookEditor.visibleRanges), 50);
|
|
54
|
+
const decorators = ( new Map());
|
|
55
|
+
let updatedCellDecoratorsOnceBefore = false;
|
|
56
|
+
let updatedDeletedInsertedDecoratorsOnceBefore = false;
|
|
57
|
+
const clearDecorators = () => {
|
|
58
|
+
dispose(Array.from(( decorators.values())));
|
|
59
|
+
decorators.clear();
|
|
60
|
+
this.deletedCellDecorator.clear();
|
|
61
|
+
this.insertedCellDecorator.clear();
|
|
62
|
+
};
|
|
63
|
+
this._register(toDisposable(() => clearDecorators()));
|
|
64
|
+
let notebookSynchronizer;
|
|
65
|
+
const entryObs = derived((r) => {
|
|
66
|
+
const session = this._chatEditingService.currentEditingSessionObs.read(r);
|
|
67
|
+
const model = notebookModel.read(r);
|
|
68
|
+
if (!model || !session) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
return session.readEntry(model.uri, r);
|
|
72
|
+
}).recomputeInitiallyAndOnChange(this._store);
|
|
73
|
+
this._register(autorun(r => {
|
|
74
|
+
const entry = entryObs.read(r);
|
|
75
|
+
const model = notebookModel.read(r);
|
|
76
|
+
if (!entry || !model || entry.state.read(r) !== WorkingSetEntryState.Modified) {
|
|
77
|
+
clearDecorators();
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
const notebookDiffInfo = derivedWithStore(this, (r, store) => {
|
|
81
|
+
const entry = entryObs.read(r);
|
|
82
|
+
const model = notebookModel.read(r);
|
|
83
|
+
if (!entry || !model) {
|
|
84
|
+
if (notebookSynchronizer && model) {
|
|
85
|
+
notebookSynchronizer.object.revert();
|
|
86
|
+
}
|
|
87
|
+
return observableValue('DefaultDiffIno', undefined);
|
|
88
|
+
}
|
|
89
|
+
notebookSynchronizer = notebookSynchronizer || this._register(this.synchronizerFactory.getOrCreate(model));
|
|
90
|
+
this.originalModelRefFactory.getOrCreate(entry, model.viewType).then(ref => originalModel.set(this._register(ref).object, undefined));
|
|
91
|
+
return notebookSynchronizer.object.diffInfo;
|
|
92
|
+
}).recomputeInitiallyAndOnChange(this._store).flatten();
|
|
93
|
+
const notebookCellDiffInfo = ( notebookDiffInfo.map(d => d?.cellDiff));
|
|
94
|
+
this._register(instantiationService.createInstance(NotebookChatActionsOverlayController, notebookEditor, notebookCellDiffInfo, this.deletedCellDecorator));
|
|
95
|
+
this._register(autorun(r => {
|
|
96
|
+
entryObs.read(r);
|
|
97
|
+
clearDecorators();
|
|
98
|
+
}));
|
|
99
|
+
this._register(autorun(r => {
|
|
100
|
+
const diffs = notebookDiffInfo.read(r);
|
|
101
|
+
if (!diffs || !diffs.cellDiff.length) {
|
|
102
|
+
clearDecorators();
|
|
103
|
+
this._ctxHasEditorModification.reset();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this._ctxHasEditorModification.set(true);
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
this._register(autorun(r => {
|
|
110
|
+
const entry = entryObs.read(r);
|
|
111
|
+
const diffInfo = notebookDiffInfo.read(r);
|
|
112
|
+
const modified = notebookModel.read(r);
|
|
113
|
+
const original = originalModel.read(r);
|
|
114
|
+
onDidChangeVisibleRanges.read(r);
|
|
115
|
+
if (!entry || !modified || !original || !diffInfo) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (diffInfo && updatedCellDecoratorsOnceBefore && (diffInfo.modelVersion !== modified.versionId)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
updatedCellDecoratorsOnceBefore = true;
|
|
122
|
+
const validDiffDecorators = ( new Set());
|
|
123
|
+
diffInfo.cellDiff.forEach((diff) => {
|
|
124
|
+
if (diff.type === 'modified') {
|
|
125
|
+
const modifiedCell = modified.cells[diff.modifiedCellIndex];
|
|
126
|
+
const originalCell = original.cells[diff.originalCellIndex];
|
|
127
|
+
const editor = this.notebookEditor.codeEditors.find(([vm,]) => vm.handle === modifiedCell.handle)?.[1];
|
|
128
|
+
if (editor) {
|
|
129
|
+
const currentDecorator = decorators.get(modifiedCell);
|
|
130
|
+
if ((currentDecorator?.modifiedCell !== modifiedCell || currentDecorator?.originalCell !== originalCell)) {
|
|
131
|
+
currentDecorator?.dispose();
|
|
132
|
+
const decorator = this.instantiationService.createInstance(NotebookCellDiffDecorator, notebookEditor, modifiedCell, originalCell);
|
|
133
|
+
decorators.set(modifiedCell, decorator);
|
|
134
|
+
validDiffDecorators.add(decorator);
|
|
135
|
+
this._register(editor.onDidDispose(() => {
|
|
136
|
+
decorator.dispose();
|
|
137
|
+
if (decorators.get(modifiedCell) === decorator) {
|
|
138
|
+
decorators.delete(modifiedCell);
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
else if (currentDecorator) {
|
|
143
|
+
validDiffDecorators.add(currentDecorator);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
decorators.forEach((v, cell) => {
|
|
149
|
+
if (!( validDiffDecorators.has(v))) {
|
|
150
|
+
v.dispose();
|
|
151
|
+
decorators.delete(cell);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}));
|
|
155
|
+
this._register(autorun(r => {
|
|
156
|
+
const entry = entryObs.read(r);
|
|
157
|
+
const diffInfo = notebookDiffInfo.read(r);
|
|
158
|
+
const modified = notebookModel.read(r);
|
|
159
|
+
const original = originalModel.read(r);
|
|
160
|
+
const ready = readyToRenderViewzones.read(r);
|
|
161
|
+
if (!ready || !entry || !modified || !original || !diffInfo) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (diffInfo && updatedDeletedInsertedDecoratorsOnceBefore && (diffInfo.modelVersion !== modified.versionId)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
updatedDeletedInsertedDecoratorsOnceBefore = true;
|
|
168
|
+
this.insertedCellDecorator.apply(diffInfo.cellDiff);
|
|
169
|
+
this.deletedCellDecorator.apply(diffInfo.cellDiff, original);
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
NotebookChatEditorController = ( __decorate([
|
|
174
|
+
( __param(1, IChatEditingService)),
|
|
175
|
+
( __param(2, INotebookOriginalModelReferenceFactory)),
|
|
176
|
+
( __param(3, INotebookModelSynchronizerFactory)),
|
|
177
|
+
( __param(4, IInstantiationService)),
|
|
178
|
+
( __param(5, IContextKeyService))
|
|
179
|
+
], NotebookChatEditorController));
|
|
180
|
+
registerNotebookContribution(NotebookChatEditorControllerContrib.ID, NotebookChatEditorControllerContrib);
|
|
181
|
+
|
|
182
|
+
export { NotebookChatEditorControllerContrib };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IReference, ReferenceCollection } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
4
|
+
import { CellKind } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon";
|
|
5
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
6
|
+
import { ILanguageService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language";
|
|
7
|
+
import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model";
|
|
8
|
+
import { INotebookOriginalCellModelFactory } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalCellModelFactory.service";
|
|
9
|
+
export declare class OriginalNotebookCellModelReferenceCollection extends ReferenceCollection<ITextModel> {
|
|
10
|
+
private readonly modelService;
|
|
11
|
+
private readonly _languageService;
|
|
12
|
+
constructor(modelService: IModelService, _languageService: ILanguageService);
|
|
13
|
+
protected createReferencedObject(_key: string, uri: URI, cellValue: string, language: string, cellKind: CellKind): ITextModel;
|
|
14
|
+
protected destroyReferencedObject(_key: string, model: ITextModel): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class OriginalNotebookCellModelFactory implements INotebookOriginalCellModelFactory {
|
|
17
|
+
readonly _serviceBrand: undefined;
|
|
18
|
+
private readonly _data;
|
|
19
|
+
constructor(instantiationService: IInstantiationService);
|
|
20
|
+
getOrCreate(uri: URI, cellValue: string, language: string, cellKind: CellKind): IReference<ITextModel>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { ReferenceCollection } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
|
+
import { CellKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
6
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
7
|
+
import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language';
|
|
8
|
+
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model';
|
|
9
|
+
|
|
10
|
+
let OriginalNotebookCellModelReferenceCollection = class OriginalNotebookCellModelReferenceCollection extends ReferenceCollection {
|
|
11
|
+
constructor(modelService, _languageService) {
|
|
12
|
+
super();
|
|
13
|
+
this.modelService = modelService;
|
|
14
|
+
this._languageService = _languageService;
|
|
15
|
+
}
|
|
16
|
+
createReferencedObject(_key, uri, cellValue, language, cellKind) {
|
|
17
|
+
const scheme = `${uri.scheme}-chat-edit`;
|
|
18
|
+
const originalCellUri = ( URI.from({ scheme, fragment: uri.fragment, path: uri.path }));
|
|
19
|
+
const languageSelection = this._languageService.getLanguageIdByLanguageName(language) ? this._languageService.createById(language) : cellKind === CellKind.Markup ? this._languageService.createById('markdown') : null;
|
|
20
|
+
return this.modelService.createModel(cellValue, languageSelection, originalCellUri);
|
|
21
|
+
}
|
|
22
|
+
destroyReferencedObject(_key, model) {
|
|
23
|
+
model.dispose();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
OriginalNotebookCellModelReferenceCollection = ( __decorate([
|
|
27
|
+
( __param(0, IModelService)),
|
|
28
|
+
( __param(1, ILanguageService))
|
|
29
|
+
], OriginalNotebookCellModelReferenceCollection));
|
|
30
|
+
let OriginalNotebookCellModelFactory = class OriginalNotebookCellModelFactory {
|
|
31
|
+
constructor(instantiationService) {
|
|
32
|
+
this._data = instantiationService.createInstance(OriginalNotebookCellModelReferenceCollection);
|
|
33
|
+
}
|
|
34
|
+
getOrCreate(uri, cellValue, language, cellKind) {
|
|
35
|
+
return this._data.acquire(( uri.toString()), uri, cellValue, language, cellKind);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
OriginalNotebookCellModelFactory = ( __decorate([
|
|
39
|
+
( __param(0, IInstantiationService))
|
|
40
|
+
], OriginalNotebookCellModelFactory));
|
|
41
|
+
|
|
42
|
+
export { OriginalNotebookCellModelFactory, OriginalNotebookCellModelReferenceCollection };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IReference, ReferenceCollection } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IModifiedFileEntry } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService";
|
|
3
|
+
import { INotebookService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service";
|
|
4
|
+
import { NotebookTextModel } from "../../../common/model/notebookTextModel.js";
|
|
5
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
6
|
+
import { INotebookOriginalModelReferenceFactory } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/contrib/chatEdit/notebookOriginalModelRefFactory.service";
|
|
7
|
+
export declare class OriginalNotebookModelReferenceCollection extends ReferenceCollection<Promise<NotebookTextModel>> {
|
|
8
|
+
private readonly notebookService;
|
|
9
|
+
private readonly modelsToDispose;
|
|
10
|
+
constructor(notebookService: INotebookService);
|
|
11
|
+
protected createReferencedObject(key: string, fileEntry: IModifiedFileEntry, viewType: string): Promise<NotebookTextModel>;
|
|
12
|
+
protected destroyReferencedObject(key: string, modelPromise: Promise<NotebookTextModel>): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class NotebookOriginalModelReferenceFactory implements INotebookOriginalModelReferenceFactory {
|
|
15
|
+
private readonly instantiationService;
|
|
16
|
+
readonly _serviceBrand: undefined;
|
|
17
|
+
private _resourceModelCollection;
|
|
18
|
+
private get resourceModelCollection();
|
|
19
|
+
private _asyncModelCollection;
|
|
20
|
+
private get asyncModelCollection();
|
|
21
|
+
constructor(instantiationService: IInstantiationService);
|
|
22
|
+
getOrCreate(fileEntry: IModifiedFileEntry, viewType: string): Promise<IReference<NotebookTextModel>>;
|
|
23
|
+
}
|