@codingame/monaco-vscode-interactive-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.
- package/interactive.js +1 -1
- package/package.json +2 -2
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/external/tslib/tslib.es6.js +0 -11
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactive.contribution.js +0 -708
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveCommon.js +0 -8
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditor.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditor.js +0 -587
- package/vscode/src/vs/workbench/contrib/interactive/browser/media/interactive.css.js +0 -6
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RawContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
2
|
-
|
|
3
|
-
const INTERACTIVE_INPUT_CURSOR_BOUNDARY = ( new RawContextKey('interactiveInputCursorAtBoundary', 'none'));
|
|
4
|
-
const InteractiveWindowSetting = {
|
|
5
|
-
interactiveWindowAlwaysScrollOnNewCell: 'interactiveWindow.alwaysScrollOnNewCell'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { INTERACTIVE_INPUT_CURSOR_BOUNDARY, InteractiveWindowSetting };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import n from '../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
|
|
2
|
-
|
|
3
|
-
var css = ".interactive-editor .input-cell-container:focus-within .input-editor-container .monaco-editor{outline:solid 1px var(--vscode-notebook-focusedCellBorder)}.interactive-editor .input-cell-container .input-editor-container .monaco-editor{outline:solid 1px var(--vscode-notebook-inactiveFocusedCellBorder)}.interactive-editor .input-cell-container .input-focus-indicator{top:8px}.interactive-editor .input-cell-container .margin-view-overlays,.interactive-editor .input-cell-container .monaco-editor-background{background-color:var(--vscode-notebook-cellEditorBackground,var(--vscode-editor-background))}";
|
|
4
|
-
n(css,{});
|
|
5
|
-
|
|
6
|
-
export { css, css as default };
|
|
@@ -1,587 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './media/interactive.css.js';
|
|
3
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
-
import { getWindowById, append, $, createStyleSheet, getWindow, Dimension } from 'vscode/vscode/vs/base/browser/dom';
|
|
5
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
6
|
-
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
7
|
-
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
8
|
-
import { CodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/codeEditorWidget';
|
|
9
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
10
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
11
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
12
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
13
|
-
import { resolveColorValue, editorForeground } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
|
|
14
|
-
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
15
|
-
import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
16
|
-
import { getSimpleEditorOptions } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
|
|
17
|
-
import { InteractiveEditorInput } from 'vscode/vscode/vs/workbench/contrib/interactive/browser/interactiveEditorInput';
|
|
18
|
-
import { NotebookEditorExtensionsRegistry } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
19
|
-
import { INotebookEditorService } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService';
|
|
20
|
-
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
21
|
-
import { ExecutionStateCellStatusBarContrib, TimerCellStatusBarContrib } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController';
|
|
22
|
-
import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService';
|
|
23
|
-
import { PLAINTEXT_LANGUAGE_ID } from 'vscode/vscode/vs/editor/common/languages/modesRegistry';
|
|
24
|
-
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
25
|
-
import { MenuId, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
26
|
-
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
27
|
-
import { INTERACTIVE_INPUT_CURSOR_BOUNDARY, InteractiveWindowSetting } from './interactiveCommon.js';
|
|
28
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
29
|
-
import { NotebookOptions } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookOptions';
|
|
30
|
-
import { ToolBar } from 'vscode/vscode/vs/base/browser/ui/toolbar/toolbar';
|
|
31
|
-
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
32
|
-
import { createActionViewItem, createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
33
|
-
import { EditorExtensionsRegistry } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
34
|
-
import { ParameterHintsController } from 'vscode/vscode/vs/editor/contrib/parameterHints/browser/parameterHints';
|
|
35
|
-
import { MenuPreventer } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/menuPreventer';
|
|
36
|
-
import { SelectionClipboardContributionID } from 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/selectionClipboard';
|
|
37
|
-
import { ContextMenuController } from 'vscode/vscode/vs/editor/contrib/contextmenu/browser/contextmenu';
|
|
38
|
-
import { SuggestController } from 'vscode/vscode/vs/editor/contrib/suggest/browser/suggestController';
|
|
39
|
-
import { SnippetController2 } from 'vscode/vscode/vs/editor/contrib/snippet/browser/snippetController2';
|
|
40
|
-
import { TabCompletionController } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/tabCompletion';
|
|
41
|
-
import { HoverController } from 'vscode/vscode/vs/editor/contrib/hover/browser/hover';
|
|
42
|
-
import { MarkerController } from 'vscode/vscode/vs/editor/contrib/gotoError/browser/gotoError';
|
|
43
|
-
import { ITextResourceConfigurationService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
|
|
44
|
-
import { NotebookExecutionType, INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
|
|
45
|
-
import { NOTEBOOK_KERNEL } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
46
|
-
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
47
|
-
import { isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
48
|
-
import { NotebookFindContrib } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget';
|
|
49
|
-
import { INTERACTIVE_WINDOW_EDITOR_ID } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
50
|
-
import './interactiveEditor.css.js';
|
|
51
|
-
import { deepClone } from 'vscode/vscode/vs/base/common/objects';
|
|
52
|
-
import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
53
|
-
|
|
54
|
-
const DECORATION_KEY = 'interactiveInputDecoration';
|
|
55
|
-
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState';
|
|
56
|
-
const INPUT_CELL_VERTICAL_PADDING = 8;
|
|
57
|
-
const INPUT_CELL_HORIZONTAL_PADDING_RIGHT = 10;
|
|
58
|
-
const INPUT_EDITOR_PADDING = 8;
|
|
59
|
-
let InteractiveEditor = class InteractiveEditor extends EditorPane {
|
|
60
|
-
get onDidFocus() { return this._onDidFocusWidget.event; }
|
|
61
|
-
constructor(telemetryService, themeService, storageService, instantiationService, notebookWidgetService, contextKeyService, codeEditorService, notebookKernelService, languageService, keybindingService, configurationService, menuService, contextMenuService, editorGroupService, textResourceConfigurationService, notebookExecutionStateService, extensionService) {
|
|
62
|
-
super(INTERACTIVE_WINDOW_EDITOR_ID, telemetryService, themeService, storageService);
|
|
63
|
-
this._notebookWidget = { value: undefined };
|
|
64
|
-
this._widgetDisposableStore = this._register(( new DisposableStore()));
|
|
65
|
-
this._groupListener = this._register(( new DisposableStore()));
|
|
66
|
-
this._onDidFocusWidget = this._register(( new Emitter()));
|
|
67
|
-
this._onDidChangeSelection = this._register(( new Emitter()));
|
|
68
|
-
this.onDidChangeSelection = this._onDidChangeSelection.event;
|
|
69
|
-
this._instantiationService = instantiationService;
|
|
70
|
-
this._notebookWidgetService = notebookWidgetService;
|
|
71
|
-
this._contextKeyService = contextKeyService;
|
|
72
|
-
this._configurationService = configurationService;
|
|
73
|
-
this._notebookKernelService = notebookKernelService;
|
|
74
|
-
this._languageService = languageService;
|
|
75
|
-
this._keybindingService = keybindingService;
|
|
76
|
-
this._menuService = menuService;
|
|
77
|
-
this._contextMenuService = contextMenuService;
|
|
78
|
-
this._editorGroupService = editorGroupService;
|
|
79
|
-
this._notebookExecutionStateService = notebookExecutionStateService;
|
|
80
|
-
this._extensionService = extensionService;
|
|
81
|
-
this._editorOptions = this._computeEditorOptions();
|
|
82
|
-
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
83
|
-
if (e.affectsConfiguration('editor') || e.affectsConfiguration('notebook')) {
|
|
84
|
-
this._editorOptions = this._computeEditorOptions();
|
|
85
|
-
}
|
|
86
|
-
}));
|
|
87
|
-
this._notebookOptions = ( new NotebookOptions(
|
|
88
|
-
getWindowById(this.group?.windowId, true).window ?? mainWindow,
|
|
89
|
-
configurationService,
|
|
90
|
-
notebookExecutionStateService,
|
|
91
|
-
codeEditorService,
|
|
92
|
-
true,
|
|
93
|
-
{ cellToolbarInteraction: 'hover', globalToolbar: true, stickyScrollEnabled: false, dragAndDropEnabled: false }
|
|
94
|
-
));
|
|
95
|
-
this._editorMemento = this.getEditorMemento(editorGroupService, textResourceConfigurationService, INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY);
|
|
96
|
-
codeEditorService.registerDecorationType('interactive-decoration', DECORATION_KEY, {});
|
|
97
|
-
this._register(this._keybindingService.onDidUpdateKeybindings(this._updateInputDecoration, this));
|
|
98
|
-
this._register(this._notebookExecutionStateService.onDidChangeExecution((e) => {
|
|
99
|
-
if (e.type === NotebookExecutionType.cell && isEqual(e.notebook, this._notebookWidget.value?.viewModel?.notebookDocument.uri)) {
|
|
100
|
-
const cell = this._notebookWidget.value?.getCellByHandle(e.cellHandle);
|
|
101
|
-
if (cell && e.changed?.state) {
|
|
102
|
-
this._scrollIfNecessary(cell);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
get inputCellContainerHeight() {
|
|
108
|
-
return 19 + 2 + INPUT_CELL_VERTICAL_PADDING * 2 + INPUT_EDITOR_PADDING * 2;
|
|
109
|
-
}
|
|
110
|
-
get inputCellEditorHeight() {
|
|
111
|
-
return 19 + INPUT_EDITOR_PADDING * 2;
|
|
112
|
-
}
|
|
113
|
-
createEditor(parent) {
|
|
114
|
-
this._rootElement = append(parent, $('.interactive-editor'));
|
|
115
|
-
this._rootElement.style.position = 'relative';
|
|
116
|
-
this._notebookEditorContainer = append(this._rootElement, $('.notebook-editor-container'));
|
|
117
|
-
this._inputCellContainer = append(this._rootElement, $('.input-cell-container'));
|
|
118
|
-
this._inputCellContainer.style.position = 'absolute';
|
|
119
|
-
this._inputCellContainer.style.height = `${this.inputCellContainerHeight}px`;
|
|
120
|
-
this._inputFocusIndicator = append(this._inputCellContainer, $('.input-focus-indicator'));
|
|
121
|
-
this._inputRunButtonContainer = append(this._inputCellContainer, $('.run-button-container'));
|
|
122
|
-
this._setupRunButtonToolbar(this._inputRunButtonContainer);
|
|
123
|
-
this._inputEditorContainer = append(this._inputCellContainer, $('.input-editor-container'));
|
|
124
|
-
this._createLayoutStyles();
|
|
125
|
-
}
|
|
126
|
-
_setupRunButtonToolbar(runButtonContainer) {
|
|
127
|
-
const menu = this._register(this._menuService.createMenu(MenuId.InteractiveInputExecute, this._contextKeyService));
|
|
128
|
-
this._runbuttonToolbar = this._register(( new ToolBar(runButtonContainer, this._contextMenuService, {
|
|
129
|
-
getKeyBinding: action => this._keybindingService.lookupKeybinding(action.id),
|
|
130
|
-
actionViewItemProvider: (action, options) => {
|
|
131
|
-
return createActionViewItem(this._instantiationService, action, options);
|
|
132
|
-
},
|
|
133
|
-
renderDropdownAsChildElement: true
|
|
134
|
-
})));
|
|
135
|
-
const primary = [];
|
|
136
|
-
const secondary = [];
|
|
137
|
-
const result = { primary, secondary };
|
|
138
|
-
createAndFillInActionBarActions(menu, { shouldForwardArgs: true }, result);
|
|
139
|
-
this._runbuttonToolbar.setActions([...primary, ...secondary]);
|
|
140
|
-
}
|
|
141
|
-
_createLayoutStyles() {
|
|
142
|
-
this._styleElement = createStyleSheet(this._rootElement);
|
|
143
|
-
const styleSheets = [];
|
|
144
|
-
const { codeCellLeftMargin, cellRunGutter } = this._notebookOptions.getLayoutConfiguration();
|
|
145
|
-
const { focusIndicator } = this._notebookOptions.getDisplayOptions();
|
|
146
|
-
const leftMargin = this._notebookOptions.getCellEditorContainerLeftMargin();
|
|
147
|
-
styleSheets.push(`
|
|
148
|
-
.interactive-editor .input-cell-container {
|
|
149
|
-
padding: ${INPUT_CELL_VERTICAL_PADDING}px ${INPUT_CELL_HORIZONTAL_PADDING_RIGHT}px ${INPUT_CELL_VERTICAL_PADDING}px ${leftMargin}px;
|
|
150
|
-
}
|
|
151
|
-
`);
|
|
152
|
-
if (focusIndicator === 'gutter') {
|
|
153
|
-
styleSheets.push(`
|
|
154
|
-
.interactive-editor .input-cell-container:focus-within .input-focus-indicator::before {
|
|
155
|
-
border-color: var(--vscode-notebook-focusedCellBorder) !important;
|
|
156
|
-
}
|
|
157
|
-
.interactive-editor .input-focus-indicator::before {
|
|
158
|
-
border-color: var(--vscode-notebook-inactiveFocusedCellBorder) !important;
|
|
159
|
-
}
|
|
160
|
-
.interactive-editor .input-cell-container .input-focus-indicator {
|
|
161
|
-
display: block;
|
|
162
|
-
top: ${INPUT_CELL_VERTICAL_PADDING}px;
|
|
163
|
-
}
|
|
164
|
-
.interactive-editor .input-cell-container {
|
|
165
|
-
border-top: 1px solid var(--vscode-notebook-inactiveFocusedCellBorder);
|
|
166
|
-
}
|
|
167
|
-
`);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
styleSheets.push(`
|
|
171
|
-
.interactive-editor .input-cell-container {
|
|
172
|
-
border-top: 1px solid var(--vscode-notebook-inactiveFocusedCellBorder);
|
|
173
|
-
}
|
|
174
|
-
.interactive-editor .input-cell-container .input-focus-indicator {
|
|
175
|
-
display: none;
|
|
176
|
-
}
|
|
177
|
-
`);
|
|
178
|
-
}
|
|
179
|
-
styleSheets.push(`
|
|
180
|
-
.interactive-editor .input-cell-container .run-button-container {
|
|
181
|
-
width: ${cellRunGutter}px;
|
|
182
|
-
left: ${codeCellLeftMargin}px;
|
|
183
|
-
margin-top: ${INPUT_EDITOR_PADDING - 2}px;
|
|
184
|
-
}
|
|
185
|
-
`);
|
|
186
|
-
this._styleElement.textContent = styleSheets.join('\n');
|
|
187
|
-
}
|
|
188
|
-
_computeEditorOptions() {
|
|
189
|
-
let overrideIdentifier = undefined;
|
|
190
|
-
if (this._codeEditorWidget) {
|
|
191
|
-
overrideIdentifier = this._codeEditorWidget.getModel()?.getLanguageId();
|
|
192
|
-
}
|
|
193
|
-
const editorOptions = deepClone(this._configurationService.getValue('editor', { overrideIdentifier }));
|
|
194
|
-
const editorOptionsOverride = getSimpleEditorOptions(this._configurationService);
|
|
195
|
-
const computed = ( Object.freeze({
|
|
196
|
-
...editorOptions,
|
|
197
|
-
...editorOptionsOverride,
|
|
198
|
-
...{
|
|
199
|
-
glyphMargin: true,
|
|
200
|
-
padding: {
|
|
201
|
-
top: INPUT_EDITOR_PADDING,
|
|
202
|
-
bottom: INPUT_EDITOR_PADDING
|
|
203
|
-
},
|
|
204
|
-
hover: {
|
|
205
|
-
enabled: true
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}));
|
|
209
|
-
return computed;
|
|
210
|
-
}
|
|
211
|
-
saveState() {
|
|
212
|
-
this._saveEditorViewState(this.input);
|
|
213
|
-
super.saveState();
|
|
214
|
-
}
|
|
215
|
-
getViewState() {
|
|
216
|
-
const input = this.input;
|
|
217
|
-
if (!(input instanceof InteractiveEditorInput)) {
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
this._saveEditorViewState(input);
|
|
221
|
-
return this._loadNotebookEditorViewState(input);
|
|
222
|
-
}
|
|
223
|
-
_saveEditorViewState(input) {
|
|
224
|
-
if (this.group && this._notebookWidget.value && input instanceof InteractiveEditorInput) {
|
|
225
|
-
if (this._notebookWidget.value.isDisposed) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
const state = this._notebookWidget.value.getEditorViewState();
|
|
229
|
-
const editorState = this._codeEditorWidget.saveViewState();
|
|
230
|
-
this._editorMemento.saveEditorState(this.group, input.notebookEditorInput.resource, {
|
|
231
|
-
notebook: state,
|
|
232
|
-
input: editorState
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
_loadNotebookEditorViewState(input) {
|
|
237
|
-
let result;
|
|
238
|
-
if (this.group) {
|
|
239
|
-
result = this._editorMemento.loadEditorState(this.group, input.notebookEditorInput.resource);
|
|
240
|
-
}
|
|
241
|
-
if (result) {
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
for (const group of this._editorGroupService.getGroups(1 )) {
|
|
245
|
-
if (group.activeEditorPane !== this && group.activeEditorPane === this && group.activeEditor?.matches(input)) {
|
|
246
|
-
const notebook = this._notebookWidget.value?.getEditorViewState();
|
|
247
|
-
const input = this._codeEditorWidget.saveViewState();
|
|
248
|
-
return {
|
|
249
|
-
notebook,
|
|
250
|
-
input
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
async setInput(input, options, context, token) {
|
|
257
|
-
const group = this.group;
|
|
258
|
-
const notebookInput = input.notebookEditorInput;
|
|
259
|
-
this._notebookWidget.value?.onWillHide();
|
|
260
|
-
this._codeEditorWidget?.dispose();
|
|
261
|
-
this._widgetDisposableStore.clear();
|
|
262
|
-
this._notebookWidget = this._instantiationService.invokeFunction(this._notebookWidgetService.retrieveWidget, group, notebookInput, {
|
|
263
|
-
isEmbedded: true,
|
|
264
|
-
isReadOnly: true,
|
|
265
|
-
contributions: NotebookEditorExtensionsRegistry.getSomeEditorContributions([
|
|
266
|
-
ExecutionStateCellStatusBarContrib.id,
|
|
267
|
-
TimerCellStatusBarContrib.id,
|
|
268
|
-
NotebookFindContrib.id
|
|
269
|
-
]),
|
|
270
|
-
menuIds: {
|
|
271
|
-
notebookToolbar: MenuId.InteractiveToolbar,
|
|
272
|
-
cellTitleToolbar: MenuId.InteractiveCellTitle,
|
|
273
|
-
cellDeleteToolbar: MenuId.InteractiveCellDelete,
|
|
274
|
-
cellInsertToolbar: MenuId.NotebookCellBetween,
|
|
275
|
-
cellTopInsertToolbar: MenuId.NotebookCellListTop,
|
|
276
|
-
cellExecuteToolbar: MenuId.InteractiveCellExecute,
|
|
277
|
-
cellExecutePrimary: undefined
|
|
278
|
-
},
|
|
279
|
-
cellEditorContributions: EditorExtensionsRegistry.getSomeEditorContributions([
|
|
280
|
-
SelectionClipboardContributionID,
|
|
281
|
-
ContextMenuController.ID,
|
|
282
|
-
HoverController.ID,
|
|
283
|
-
MarkerController.ID
|
|
284
|
-
]),
|
|
285
|
-
options: this._notebookOptions
|
|
286
|
-
}, undefined, this._rootElement ? getWindow(this._rootElement) : mainWindow);
|
|
287
|
-
this._codeEditorWidget = this._instantiationService.createInstance(CodeEditorWidget, this._inputEditorContainer, this._editorOptions, {
|
|
288
|
-
...{
|
|
289
|
-
isSimpleWidget: false,
|
|
290
|
-
contributions: EditorExtensionsRegistry.getSomeEditorContributions([
|
|
291
|
-
MenuPreventer.ID,
|
|
292
|
-
SelectionClipboardContributionID,
|
|
293
|
-
ContextMenuController.ID,
|
|
294
|
-
SuggestController.ID,
|
|
295
|
-
ParameterHintsController.ID,
|
|
296
|
-
SnippetController2.ID,
|
|
297
|
-
TabCompletionController.ID,
|
|
298
|
-
HoverController.ID,
|
|
299
|
-
MarkerController.ID
|
|
300
|
-
])
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
if (this._lastLayoutDimensions) {
|
|
304
|
-
this._notebookEditorContainer.style.height = `${this._lastLayoutDimensions.dimension.height - this.inputCellContainerHeight}px`;
|
|
305
|
-
this._notebookWidget.value.layout(new Dimension(this._lastLayoutDimensions.dimension.width, this._lastLayoutDimensions.dimension.height - this.inputCellContainerHeight), this._notebookEditorContainer);
|
|
306
|
-
const leftMargin = this._notebookOptions.getCellEditorContainerLeftMargin();
|
|
307
|
-
const maxHeight = Math.min(this._lastLayoutDimensions.dimension.height / 2, this.inputCellEditorHeight);
|
|
308
|
-
this._codeEditorWidget.layout(this._validateDimension(this._lastLayoutDimensions.dimension.width - leftMargin - INPUT_CELL_HORIZONTAL_PADDING_RIGHT, maxHeight));
|
|
309
|
-
this._inputFocusIndicator.style.height = `${this.inputCellEditorHeight}px`;
|
|
310
|
-
this._inputCellContainer.style.top = `${this._lastLayoutDimensions.dimension.height - this.inputCellContainerHeight}px`;
|
|
311
|
-
this._inputCellContainer.style.width = `${this._lastLayoutDimensions.dimension.width}px`;
|
|
312
|
-
}
|
|
313
|
-
await super.setInput(input, options, context, token);
|
|
314
|
-
const model = await input.resolve();
|
|
315
|
-
if (this._runbuttonToolbar) {
|
|
316
|
-
this._runbuttonToolbar.context = input.resource;
|
|
317
|
-
}
|
|
318
|
-
if (model === null) {
|
|
319
|
-
throw new Error('The Interactive Window model could not be resolved');
|
|
320
|
-
}
|
|
321
|
-
this._notebookWidget.value?.setParentContextKeyService(this._contextKeyService);
|
|
322
|
-
const viewState = options?.viewState ?? this._loadNotebookEditorViewState(input);
|
|
323
|
-
await this._extensionService.whenInstalledExtensionsRegistered();
|
|
324
|
-
await this._notebookWidget.value.setModel(model.notebook, viewState?.notebook);
|
|
325
|
-
model.notebook.setCellCollapseDefault(this._notebookOptions.getCellCollapseDefault());
|
|
326
|
-
this._notebookWidget.value.setOptions({
|
|
327
|
-
isReadOnly: true
|
|
328
|
-
});
|
|
329
|
-
this._widgetDisposableStore.add(this._notebookWidget.value.onDidResizeOutput((cvm) => {
|
|
330
|
-
this._scrollIfNecessary(cvm);
|
|
331
|
-
}));
|
|
332
|
-
this._widgetDisposableStore.add(this._notebookWidget.value.onDidFocusWidget(() => this._onDidFocusWidget.fire()));
|
|
333
|
-
this._widgetDisposableStore.add(this._notebookOptions.onDidChangeOptions(e => {
|
|
334
|
-
if (e.compactView || e.focusIndicator) {
|
|
335
|
-
this._styleElement?.remove();
|
|
336
|
-
this._createLayoutStyles();
|
|
337
|
-
}
|
|
338
|
-
if (this._lastLayoutDimensions && this.isVisible()) {
|
|
339
|
-
this.layout(this._lastLayoutDimensions.dimension, this._lastLayoutDimensions.position);
|
|
340
|
-
}
|
|
341
|
-
if (e.interactiveWindowCollapseCodeCells) {
|
|
342
|
-
model.notebook.setCellCollapseDefault(this._notebookOptions.getCellCollapseDefault());
|
|
343
|
-
}
|
|
344
|
-
}));
|
|
345
|
-
const languageId = this._notebookWidget.value?.activeKernel?.supportedLanguages[0] ?? input.language ?? PLAINTEXT_LANGUAGE_ID;
|
|
346
|
-
const editorModel = await input.resolveInput(languageId);
|
|
347
|
-
editorModel.setLanguage(languageId);
|
|
348
|
-
this._codeEditorWidget.setModel(editorModel);
|
|
349
|
-
if (viewState?.input) {
|
|
350
|
-
this._codeEditorWidget.restoreViewState(viewState.input);
|
|
351
|
-
}
|
|
352
|
-
this._editorOptions = this._computeEditorOptions();
|
|
353
|
-
this._codeEditorWidget.updateOptions(this._editorOptions);
|
|
354
|
-
this._widgetDisposableStore.add(this._codeEditorWidget.onDidFocusEditorWidget(() => this._onDidFocusWidget.fire()));
|
|
355
|
-
this._widgetDisposableStore.add(this._codeEditorWidget.onDidContentSizeChange(e => {
|
|
356
|
-
if (!e.contentHeightChanged) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (this._lastLayoutDimensions) {
|
|
360
|
-
this._layoutWidgets(this._lastLayoutDimensions.dimension, this._lastLayoutDimensions.position);
|
|
361
|
-
}
|
|
362
|
-
}));
|
|
363
|
-
this._widgetDisposableStore.add(this._codeEditorWidget.onDidChangeCursorPosition(e => this._onDidChangeSelection.fire({ reason: this._toEditorPaneSelectionChangeReason(e) })));
|
|
364
|
-
this._widgetDisposableStore.add(this._codeEditorWidget.onDidChangeModelContent(() => this._onDidChangeSelection.fire({ reason: 3 })));
|
|
365
|
-
this._widgetDisposableStore.add(this._notebookKernelService.onDidChangeNotebookAffinity(this._syncWithKernel, this));
|
|
366
|
-
this._widgetDisposableStore.add(this._notebookKernelService.onDidChangeSelectedNotebooks(this._syncWithKernel, this));
|
|
367
|
-
this._widgetDisposableStore.add(this.themeService.onDidColorThemeChange(() => {
|
|
368
|
-
if (this.isVisible()) {
|
|
369
|
-
this._updateInputDecoration();
|
|
370
|
-
}
|
|
371
|
-
}));
|
|
372
|
-
this._widgetDisposableStore.add(this._codeEditorWidget.onDidChangeModelContent(() => {
|
|
373
|
-
if (this.isVisible()) {
|
|
374
|
-
this._updateInputDecoration();
|
|
375
|
-
}
|
|
376
|
-
}));
|
|
377
|
-
const cursorAtBoundaryContext = INTERACTIVE_INPUT_CURSOR_BOUNDARY.bindTo(this._contextKeyService);
|
|
378
|
-
if (input.resource && ( input.historyService.has(input.resource))) {
|
|
379
|
-
cursorAtBoundaryContext.set('top');
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
cursorAtBoundaryContext.set('none');
|
|
383
|
-
}
|
|
384
|
-
this._widgetDisposableStore.add(this._codeEditorWidget.onDidChangeCursorPosition(({ position }) => {
|
|
385
|
-
const viewModel = this._codeEditorWidget._getViewModel();
|
|
386
|
-
const lastLineNumber = viewModel.getLineCount();
|
|
387
|
-
const lastLineCol = viewModel.getLineLength(lastLineNumber) + 1;
|
|
388
|
-
const viewPosition = viewModel.coordinatesConverter.convertModelPositionToViewPosition(position);
|
|
389
|
-
const firstLine = viewPosition.lineNumber === 1 && viewPosition.column === 1;
|
|
390
|
-
const lastLine = viewPosition.lineNumber === lastLineNumber && viewPosition.column === lastLineCol;
|
|
391
|
-
if (firstLine) {
|
|
392
|
-
if (lastLine) {
|
|
393
|
-
cursorAtBoundaryContext.set('both');
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
cursorAtBoundaryContext.set('top');
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
if (lastLine) {
|
|
401
|
-
cursorAtBoundaryContext.set('bottom');
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
cursorAtBoundaryContext.set('none');
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}));
|
|
408
|
-
this._widgetDisposableStore.add(editorModel.onDidChangeContent(() => {
|
|
409
|
-
const value = editorModel.getValue();
|
|
410
|
-
if (this.input?.resource && value !== '') {
|
|
411
|
-
this.input.historyService.replaceLast(this.input.resource, value);
|
|
412
|
-
}
|
|
413
|
-
}));
|
|
414
|
-
this._syncWithKernel();
|
|
415
|
-
}
|
|
416
|
-
setOptions(options) {
|
|
417
|
-
this._notebookWidget.value?.setOptions(options);
|
|
418
|
-
super.setOptions(options);
|
|
419
|
-
}
|
|
420
|
-
_toEditorPaneSelectionChangeReason(e) {
|
|
421
|
-
switch (e.source) {
|
|
422
|
-
case "api" : return 1 ;
|
|
423
|
-
case "code.navigation" : return 4 ;
|
|
424
|
-
case "code.jump" : return 5 ;
|
|
425
|
-
default: return 2 ;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
_cellAtBottom(cell) {
|
|
429
|
-
const visibleRanges = this._notebookWidget.value?.visibleRanges || [];
|
|
430
|
-
const cellIndex = this._notebookWidget.value?.getCellIndex(cell);
|
|
431
|
-
if (cellIndex === Math.max(...( visibleRanges.map(range => range.end - 1)))) {
|
|
432
|
-
return true;
|
|
433
|
-
}
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
_scrollIfNecessary(cvm) {
|
|
437
|
-
const index = this._notebookWidget.value.getCellIndex(cvm);
|
|
438
|
-
if (index === this._notebookWidget.value.getLength() - 1) {
|
|
439
|
-
if (this._configurationService.getValue(InteractiveWindowSetting.interactiveWindowAlwaysScrollOnNewCell) || this._cellAtBottom(cvm)) {
|
|
440
|
-
this._notebookWidget.value.scrollToBottom();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
_syncWithKernel() {
|
|
445
|
-
const notebook = this._notebookWidget.value?.textModel;
|
|
446
|
-
const textModel = this._codeEditorWidget.getModel();
|
|
447
|
-
if (notebook && textModel) {
|
|
448
|
-
const info = this._notebookKernelService.getMatchingKernel(notebook);
|
|
449
|
-
const selectedOrSuggested = info.selected
|
|
450
|
-
?? (info.suggestions.length === 1 ? info.suggestions[0] : undefined)
|
|
451
|
-
?? (info.all.length === 1 ? info.all[0] : undefined);
|
|
452
|
-
if (selectedOrSuggested) {
|
|
453
|
-
const language = selectedOrSuggested.supportedLanguages[0];
|
|
454
|
-
if (language && language !== 'plaintext') {
|
|
455
|
-
const newMode = this._languageService.createById(language).languageId;
|
|
456
|
-
textModel.setLanguage(newMode);
|
|
457
|
-
}
|
|
458
|
-
NOTEBOOK_KERNEL.bindTo(this._contextKeyService).set(selectedOrSuggested.id);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
this._updateInputDecoration();
|
|
462
|
-
}
|
|
463
|
-
layout(dimension, position) {
|
|
464
|
-
this._rootElement.classList.toggle('mid-width', dimension.width < 1000 && dimension.width >= 600);
|
|
465
|
-
this._rootElement.classList.toggle('narrow-width', dimension.width < 600);
|
|
466
|
-
const editorHeightChanged = dimension.height !== this._lastLayoutDimensions?.dimension.height;
|
|
467
|
-
this._lastLayoutDimensions = { dimension, position };
|
|
468
|
-
if (!this._notebookWidget.value) {
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
if (editorHeightChanged && this._codeEditorWidget) {
|
|
472
|
-
SuggestController.get(this._codeEditorWidget)?.cancelSuggestWidget();
|
|
473
|
-
}
|
|
474
|
-
this._notebookEditorContainer.style.height = `${this._lastLayoutDimensions.dimension.height - this.inputCellContainerHeight}px`;
|
|
475
|
-
this._layoutWidgets(dimension, position);
|
|
476
|
-
}
|
|
477
|
-
_layoutWidgets(dimension, position) {
|
|
478
|
-
const contentHeight = this._codeEditorWidget.hasModel() ? this._codeEditorWidget.getContentHeight() : this.inputCellEditorHeight;
|
|
479
|
-
const maxHeight = Math.min(dimension.height / 2, contentHeight);
|
|
480
|
-
const leftMargin = this._notebookOptions.getCellEditorContainerLeftMargin();
|
|
481
|
-
const inputCellContainerHeight = maxHeight + INPUT_CELL_VERTICAL_PADDING * 2;
|
|
482
|
-
this._notebookEditorContainer.style.height = `${dimension.height - inputCellContainerHeight}px`;
|
|
483
|
-
this._notebookWidget.value.layout(dimension.with(dimension.width, dimension.height - inputCellContainerHeight), this._notebookEditorContainer, position);
|
|
484
|
-
this._codeEditorWidget.layout(this._validateDimension(dimension.width - leftMargin - INPUT_CELL_HORIZONTAL_PADDING_RIGHT, maxHeight));
|
|
485
|
-
this._inputFocusIndicator.style.height = `${contentHeight}px`;
|
|
486
|
-
this._inputCellContainer.style.top = `${dimension.height - inputCellContainerHeight}px`;
|
|
487
|
-
this._inputCellContainer.style.width = `${dimension.width}px`;
|
|
488
|
-
}
|
|
489
|
-
_validateDimension(width, height) {
|
|
490
|
-
return new Dimension(Math.max(0, width), Math.max(0, height));
|
|
491
|
-
}
|
|
492
|
-
_updateInputDecoration() {
|
|
493
|
-
if (!this._codeEditorWidget) {
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
if (!this._codeEditorWidget.hasModel()) {
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
const model = this._codeEditorWidget.getModel();
|
|
500
|
-
const decorations = [];
|
|
501
|
-
if (model?.getValueLength() === 0) {
|
|
502
|
-
const transparentForeground = resolveColorValue(editorForeground, this.themeService.getColorTheme())?.transparent(0.4);
|
|
503
|
-
const languageId = model.getLanguageId();
|
|
504
|
-
const keybinding = this._keybindingService.lookupKeybinding('interactive.execute', this._contextKeyService)?.getLabel();
|
|
505
|
-
const text = ( localizeWithPath(
|
|
506
|
-
'vs/workbench/contrib/interactive/browser/interactiveEditor',
|
|
507
|
-
'interactiveInputPlaceHolder',
|
|
508
|
-
"Type '{0}' code here and press {1} to run",
|
|
509
|
-
languageId,
|
|
510
|
-
keybinding ?? 'ctrl+enter'
|
|
511
|
-
));
|
|
512
|
-
decorations.push({
|
|
513
|
-
range: {
|
|
514
|
-
startLineNumber: 0,
|
|
515
|
-
endLineNumber: 0,
|
|
516
|
-
startColumn: 0,
|
|
517
|
-
endColumn: 1
|
|
518
|
-
},
|
|
519
|
-
renderOptions: {
|
|
520
|
-
after: {
|
|
521
|
-
contentText: text,
|
|
522
|
-
color: transparentForeground ? ( transparentForeground.toString()) : undefined
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
this._codeEditorWidget.setDecorationsByType('interactive-decoration', DECORATION_KEY, decorations);
|
|
528
|
-
}
|
|
529
|
-
focus() {
|
|
530
|
-
super.focus();
|
|
531
|
-
this._notebookWidget.value?.onShow();
|
|
532
|
-
this._codeEditorWidget.focus();
|
|
533
|
-
}
|
|
534
|
-
focusHistory() {
|
|
535
|
-
this._notebookWidget.value.focus();
|
|
536
|
-
}
|
|
537
|
-
setEditorVisible(visible, group) {
|
|
538
|
-
super.setEditorVisible(visible, group);
|
|
539
|
-
if (group) {
|
|
540
|
-
this._groupListener.clear();
|
|
541
|
-
this._groupListener.add(group.onWillCloseEditor(e => this._saveEditorViewState(e.editor)));
|
|
542
|
-
}
|
|
543
|
-
if (!visible) {
|
|
544
|
-
this._saveEditorViewState(this.input);
|
|
545
|
-
if (this.input && this._notebookWidget.value) {
|
|
546
|
-
this._notebookWidget.value.onWillHide();
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
clearInput() {
|
|
551
|
-
if (this._notebookWidget.value) {
|
|
552
|
-
this._saveEditorViewState(this.input);
|
|
553
|
-
this._notebookWidget.value.onWillHide();
|
|
554
|
-
}
|
|
555
|
-
this._codeEditorWidget?.dispose();
|
|
556
|
-
this._notebookWidget = { value: undefined };
|
|
557
|
-
this._widgetDisposableStore.clear();
|
|
558
|
-
super.clearInput();
|
|
559
|
-
}
|
|
560
|
-
getControl() {
|
|
561
|
-
return {
|
|
562
|
-
notebookEditor: this._notebookWidget.value,
|
|
563
|
-
codeEditor: this._codeEditorWidget
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
InteractiveEditor = ( __decorate([
|
|
568
|
-
( __param(0, ITelemetryService)),
|
|
569
|
-
( __param(1, IThemeService)),
|
|
570
|
-
( __param(2, IStorageService)),
|
|
571
|
-
( __param(3, IInstantiationService)),
|
|
572
|
-
( __param(4, INotebookEditorService)),
|
|
573
|
-
( __param(5, IContextKeyService)),
|
|
574
|
-
( __param(6, ICodeEditorService)),
|
|
575
|
-
( __param(7, INotebookKernelService)),
|
|
576
|
-
( __param(8, ILanguageService)),
|
|
577
|
-
( __param(9, IKeybindingService)),
|
|
578
|
-
( __param(10, IConfigurationService)),
|
|
579
|
-
( __param(11, IMenuService)),
|
|
580
|
-
( __param(12, IContextMenuService)),
|
|
581
|
-
( __param(13, IEditorGroupsService)),
|
|
582
|
-
( __param(14, ITextResourceConfigurationService)),
|
|
583
|
-
( __param(15, INotebookExecutionStateService)),
|
|
584
|
-
( __param(16, IExtensionService))
|
|
585
|
-
], InteractiveEditor));
|
|
586
|
-
|
|
587
|
-
export { InteractiveEditor };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
|
|
2
|
-
|
|
3
|
-
var css = ".interactive-editor .input-cell-container{box-sizing:border-box}.interactive-editor .input-cell-container .input-focus-indicator{height:19px;left:0;position:absolute}.interactive-editor .input-cell-container .input-focus-indicator:before{border-left:3px solid transparent;border-radius:2px;content:\"\";height:100%;left:0;margin-left:4px;position:absolute;top:0;width:0;z-index:10}.interactive-editor .input-cell-container .run-button-container{position:absolute}.interactive-editor .input-cell-container .run-button-container .monaco-toolbar .actions-container{justify-content:center}";
|
|
4
|
-
n(css,{});
|
|
5
|
-
|
|
6
|
-
export { css, css as default };
|