@codingame/monaco-vscode-notebook-service-override 3.2.3 → 4.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/notebook.js +1 -1
- package/override/vs/platform/dialogs/common/dialogs.js +2 -0
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +9 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +61 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +11 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +9 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +1 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +293 -20
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +16 -10
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +107 -20
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +15 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +48 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +199 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +2 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +7 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +47 -26
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +6 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +11 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +20 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +15 -5
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +54 -55
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +3 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +11 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +0 -608
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -31
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.js +0 -744
- package/vscode/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService.js +0 -237
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { clearNode, WindowIdleValue } from 'vscode/vscode/vs/base/browser/dom';
|
|
4
|
+
import { ToolBar } from 'vscode/vscode/vs/base/browser/ui/toolbar/toolbar';
|
|
3
5
|
import { IconLabel } from 'vscode/vscode/vs/base/browser/ui/iconLabel/iconLabel';
|
|
4
6
|
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
5
7
|
import { createMatches } from 'vscode/vscode/vs/base/common/filters';
|
|
@@ -11,7 +13,17 @@ import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configurat
|
|
|
11
13
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
14
|
import { MarkerSeverity } from 'vscode/vscode/vs/platform/markers/common/markers';
|
|
13
15
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
14
|
-
import
|
|
16
|
+
import 'vscode/vscode/vs/platform/theme/common/colorUtils';
|
|
17
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
|
|
18
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
19
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
|
|
20
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
|
|
21
|
+
import { listErrorForeground, listWarningForeground } from 'vscode/vscode/vs/platform/theme/common/colors/listColors';
|
|
22
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
|
|
23
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
24
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
|
|
25
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
26
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
15
27
|
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
16
28
|
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
17
29
|
import { NotebookEditor } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditor';
|
|
@@ -21,25 +33,41 @@ import { SIDE_GROUP, IEditorService } from 'vscode/vscode/vs/workbench/services/
|
|
|
21
33
|
import { IOutlineService } from 'vscode/vscode/vs/workbench/services/outline/browser/outline';
|
|
22
34
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
23
35
|
import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
24
|
-
import {
|
|
36
|
+
import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
|
|
37
|
+
import { MenuRegistry, MenuId, registerAction2, Action2, MenuItemAction, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
38
|
+
import { RawContextKey, ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
39
|
+
import { MenuEntryActionViewItem, createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
40
|
+
import { disposableTimeout } from 'vscode/vscode/vs/base/common/async';
|
|
41
|
+
import { IOutlinePane } from 'vscode/vscode/vs/workbench/contrib/outline/browser/outline';
|
|
42
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
43
|
+
import { NOTEBOOK_IS_ACTIVE_EDITOR } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
25
44
|
|
|
26
45
|
var NotebookCellOutline_1;
|
|
27
46
|
class NotebookOutlineTemplate {
|
|
28
47
|
static { this.templateId = 'NotebookOutlineRenderer'; }
|
|
29
|
-
constructor(container, iconClass, iconLabel, decoration) {
|
|
48
|
+
constructor(container, iconClass, iconLabel, decoration, actionMenu, elementDisposables) {
|
|
30
49
|
this.container = container;
|
|
31
50
|
this.iconClass = iconClass;
|
|
32
51
|
this.iconLabel = iconLabel;
|
|
33
52
|
this.decoration = decoration;
|
|
53
|
+
this.actionMenu = actionMenu;
|
|
54
|
+
this.elementDisposables = elementDisposables;
|
|
34
55
|
}
|
|
35
56
|
}
|
|
36
57
|
let NotebookOutlineRenderer = class NotebookOutlineRenderer {
|
|
37
|
-
constructor(_themeService, _configurationService) {
|
|
58
|
+
constructor(_editor, _target, _themeService, _configurationService, _contextMenuService, _contextKeyService, _menuService, _instantiationService) {
|
|
59
|
+
this._editor = _editor;
|
|
60
|
+
this._target = _target;
|
|
38
61
|
this._themeService = _themeService;
|
|
39
62
|
this._configurationService = _configurationService;
|
|
63
|
+
this._contextMenuService = _contextMenuService;
|
|
64
|
+
this._contextKeyService = _contextKeyService;
|
|
65
|
+
this._menuService = _menuService;
|
|
66
|
+
this._instantiationService = _instantiationService;
|
|
40
67
|
this.templateId = NotebookOutlineTemplate.templateId;
|
|
41
68
|
}
|
|
42
69
|
renderTemplate(container) {
|
|
70
|
+
const elementDisposables = ( new DisposableStore());
|
|
43
71
|
container.classList.add('notebook-outline-element', 'show-file-icons');
|
|
44
72
|
const iconClass = document.createElement('div');
|
|
45
73
|
container.append(iconClass);
|
|
@@ -47,7 +75,17 @@ let NotebookOutlineRenderer = class NotebookOutlineRenderer {
|
|
|
47
75
|
const decoration = document.createElement('div');
|
|
48
76
|
decoration.className = 'element-decoration';
|
|
49
77
|
container.append(decoration);
|
|
50
|
-
|
|
78
|
+
const actionMenu = document.createElement('div');
|
|
79
|
+
actionMenu.className = 'action-menu';
|
|
80
|
+
container.append(actionMenu);
|
|
81
|
+
return ( new NotebookOutlineTemplate(
|
|
82
|
+
container,
|
|
83
|
+
iconClass,
|
|
84
|
+
iconLabel,
|
|
85
|
+
decoration,
|
|
86
|
+
actionMenu,
|
|
87
|
+
elementDisposables
|
|
88
|
+
));
|
|
51
89
|
}
|
|
52
90
|
renderElement(node, _index, template, _height) {
|
|
53
91
|
const extraClasses = [];
|
|
@@ -56,14 +94,18 @@ let NotebookOutlineRenderer = class NotebookOutlineRenderer {
|
|
|
56
94
|
labelEscapeNewLines: true,
|
|
57
95
|
extraClasses,
|
|
58
96
|
};
|
|
59
|
-
|
|
97
|
+
const isCodeCell = node.element.cell.cellKind === CellKind.Code;
|
|
98
|
+
if (node.element.level >= 8) {
|
|
99
|
+
template.iconClass.className = 'element-icon ' + ThemeIcon.asClassNameArray(node.element.icon).join(' ');
|
|
100
|
+
}
|
|
101
|
+
else if (isCodeCell && this._themeService.getFileIconTheme().hasFileIcons && !node.element.isExecuting) {
|
|
60
102
|
template.iconClass.className = '';
|
|
61
103
|
extraClasses.push(...getIconClassesForLanguageId(node.element.cell.language ?? ''));
|
|
62
104
|
}
|
|
63
105
|
else {
|
|
64
106
|
template.iconClass.className = 'element-icon ' + ThemeIcon.asClassNameArray(node.element.icon).join(' ');
|
|
65
107
|
}
|
|
66
|
-
template.iconLabel.setLabel(node.element.label, undefined, options);
|
|
108
|
+
template.iconLabel.setLabel(' ' + node.element.label, undefined, options);
|
|
67
109
|
const { markerInfo } = node.element;
|
|
68
110
|
template.container.style.removeProperty('--outline-element-color');
|
|
69
111
|
template.decoration.innerText = '';
|
|
@@ -95,15 +137,101 @@ let NotebookOutlineRenderer = class NotebookOutlineRenderer {
|
|
|
95
137
|
template.container.style.setProperty('--outline-element-color', color?.toString() ?? 'inherit');
|
|
96
138
|
}
|
|
97
139
|
}
|
|
140
|
+
if (this._target === 1 ) {
|
|
141
|
+
const nbCell = node.element.cell;
|
|
142
|
+
const nbViewModel = this._editor?.getViewModel();
|
|
143
|
+
if (!nbViewModel) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const idx = nbViewModel.getCellIndex(nbCell);
|
|
147
|
+
const length = isCodeCell ? 0 : nbViewModel.getFoldedLength(idx);
|
|
148
|
+
const scopedContextKeyService = template.elementDisposables.add(this._contextKeyService.createScoped(template.container));
|
|
149
|
+
NotebookOutlineContext.CellKind.bindTo(scopedContextKeyService).set(isCodeCell ? CellKind.Code : CellKind.Markup);
|
|
150
|
+
NotebookOutlineContext.CellHasChildren.bindTo(scopedContextKeyService).set(length > 0);
|
|
151
|
+
NotebookOutlineContext.CellHasHeader.bindTo(scopedContextKeyService).set(node.element.level !== 7);
|
|
152
|
+
NotebookOutlineContext.OutlineElementTarget.bindTo(scopedContextKeyService).set(this._target);
|
|
153
|
+
this.setupFolding(isCodeCell, nbViewModel, scopedContextKeyService, template, nbCell);
|
|
154
|
+
const outlineEntryToolbar = template.elementDisposables.add(( new ToolBar(template.actionMenu, this._contextMenuService, {
|
|
155
|
+
actionViewItemProvider: action => {
|
|
156
|
+
if (action instanceof MenuItemAction) {
|
|
157
|
+
return this._instantiationService.createInstance(MenuEntryActionViewItem, action, undefined);
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
},
|
|
161
|
+
})));
|
|
162
|
+
const menu = template.elementDisposables.add(this._menuService.createMenu(MenuId.NotebookOutlineActionMenu, scopedContextKeyService));
|
|
163
|
+
const actions = getOutlineToolbarActions(menu, { notebookEditor: this._editor, outlineEntry: node.element });
|
|
164
|
+
outlineEntryToolbar.setActions(actions.primary, actions.secondary);
|
|
165
|
+
this.setupToolbarListeners(outlineEntryToolbar, menu, actions, node.element, template);
|
|
166
|
+
template.actionMenu.style.padding = '0 0.8em 0 0.4em';
|
|
167
|
+
}
|
|
98
168
|
}
|
|
99
169
|
disposeTemplate(templateData) {
|
|
100
170
|
templateData.iconLabel.dispose();
|
|
171
|
+
templateData.elementDisposables.clear();
|
|
172
|
+
}
|
|
173
|
+
disposeElement(element, index, templateData, height) {
|
|
174
|
+
templateData.elementDisposables.clear();
|
|
175
|
+
clearNode(templateData.actionMenu);
|
|
176
|
+
}
|
|
177
|
+
setupFolding(isCodeCell, nbViewModel, scopedContextKeyService, template, nbCell) {
|
|
178
|
+
const foldingState = isCodeCell ? 0 : (nbCell.foldingState);
|
|
179
|
+
const foldingStateCtx = NotebookOutlineContext.CellFoldingState.bindTo(scopedContextKeyService);
|
|
180
|
+
foldingStateCtx.set(foldingState);
|
|
181
|
+
if (!isCodeCell) {
|
|
182
|
+
template.elementDisposables.add(nbViewModel.onDidFoldingStateChanged(() => {
|
|
183
|
+
const foldingState = nbCell.foldingState;
|
|
184
|
+
NotebookOutlineContext.CellFoldingState.bindTo(scopedContextKeyService).set(foldingState);
|
|
185
|
+
foldingStateCtx.set(foldingState);
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
setupToolbarListeners(toolbar, menu, initActions, entry, templateData) {
|
|
190
|
+
let dropdownIsVisible = false;
|
|
191
|
+
let deferredUpdate;
|
|
192
|
+
toolbar.setActions(initActions.primary, initActions.secondary);
|
|
193
|
+
templateData.elementDisposables.add(menu.onDidChange(() => {
|
|
194
|
+
if (dropdownIsVisible) {
|
|
195
|
+
const actions = getOutlineToolbarActions(menu, { notebookEditor: this._editor, outlineEntry: entry });
|
|
196
|
+
deferredUpdate = () => toolbar.setActions(actions.primary, actions.secondary);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const actions = getOutlineToolbarActions(menu, { notebookEditor: this._editor, outlineEntry: entry });
|
|
200
|
+
toolbar.setActions(actions.primary, actions.secondary);
|
|
201
|
+
}));
|
|
202
|
+
templateData.container.classList.remove('notebook-outline-toolbar-dropdown-active');
|
|
203
|
+
templateData.elementDisposables.add(toolbar.onDidChangeDropdownVisibility(visible => {
|
|
204
|
+
dropdownIsVisible = visible;
|
|
205
|
+
if (visible) {
|
|
206
|
+
templateData.container.classList.add('notebook-outline-toolbar-dropdown-active');
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
templateData.container.classList.remove('notebook-outline-toolbar-dropdown-active');
|
|
210
|
+
}
|
|
211
|
+
if (deferredUpdate && !visible) {
|
|
212
|
+
disposableTimeout(() => {
|
|
213
|
+
deferredUpdate?.();
|
|
214
|
+
}, 0, templateData.elementDisposables);
|
|
215
|
+
deferredUpdate = undefined;
|
|
216
|
+
}
|
|
217
|
+
}));
|
|
101
218
|
}
|
|
102
219
|
};
|
|
103
220
|
NotebookOutlineRenderer = ( __decorate([
|
|
104
|
-
( __param(
|
|
105
|
-
( __param(
|
|
221
|
+
( __param(2, IThemeService)),
|
|
222
|
+
( __param(3, IConfigurationService)),
|
|
223
|
+
( __param(4, IContextMenuService)),
|
|
224
|
+
( __param(5, IContextKeyService)),
|
|
225
|
+
( __param(6, IMenuService)),
|
|
226
|
+
( __param(7, IInstantiationService))
|
|
106
227
|
], NotebookOutlineRenderer));
|
|
228
|
+
function getOutlineToolbarActions(menu, args) {
|
|
229
|
+
const primary = [];
|
|
230
|
+
const secondary = [];
|
|
231
|
+
const result = { primary, secondary };
|
|
232
|
+
createAndFillInActionBarActions(menu, { shouldForwardArgs: true, arg: args }, result);
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
107
235
|
class NotebookOutlineAccessibility {
|
|
108
236
|
getAriaLabel(element) {
|
|
109
237
|
return element.label;
|
|
@@ -154,7 +282,7 @@ NotebookQuickPickProvider = ( __decorate([
|
|
|
154
282
|
], NotebookQuickPickProvider));
|
|
155
283
|
class NotebookComparator {
|
|
156
284
|
constructor() {
|
|
157
|
-
this._collator =
|
|
285
|
+
this._collator = new WindowIdleValue(mainWindow, () => new Intl.Collator(undefined, { numeric: true }));
|
|
158
286
|
}
|
|
159
287
|
compareByPosition(a, b) {
|
|
160
288
|
return a.index - b.index;
|
|
@@ -202,9 +330,13 @@ let NotebookCellOutline = NotebookCellOutline_1 = class NotebookCellOutline {
|
|
|
202
330
|
installSelectionListener();
|
|
203
331
|
}));
|
|
204
332
|
installSelectionListener();
|
|
205
|
-
const treeDataSource = {
|
|
333
|
+
const treeDataSource = {
|
|
334
|
+
getChildren: parent => {
|
|
335
|
+
return this.getChildren(parent, _configurationService);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
206
338
|
const delegate = ( new NotebookOutlineVirtualDelegate());
|
|
207
|
-
const renderers = [instantiationService.createInstance(NotebookOutlineRenderer)];
|
|
339
|
+
const renderers = [instantiationService.createInstance(NotebookOutlineRenderer, this._editor.getControl(), _target)];
|
|
208
340
|
const comparator = ( new NotebookComparator());
|
|
209
341
|
const options = {
|
|
210
342
|
collapseByDefault: _target === 2 || ((_target === 1 && _configurationService.getValue("outline.collapseItems" ) === "alwaysCollapse") ),
|
|
@@ -234,6 +366,29 @@ let NotebookCellOutline = NotebookCellOutline_1 = class NotebookCellOutline {
|
|
|
234
366
|
options
|
|
235
367
|
};
|
|
236
368
|
}
|
|
369
|
+
*getChildren(parent, configurationService) {
|
|
370
|
+
const showCodeCells = configurationService.getValue(NotebookSetting.outlineShowCodeCells);
|
|
371
|
+
const showCodeCellSymbols = configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
|
|
372
|
+
const showMarkdownHeadersOnly = configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly);
|
|
373
|
+
for (const entry of parent instanceof NotebookCellOutline_1 ? (this._outlineProvider?.entries ?? []) : parent.children) {
|
|
374
|
+
if (entry.cell.cellKind === CellKind.Markup) {
|
|
375
|
+
if (!showMarkdownHeadersOnly) {
|
|
376
|
+
yield entry;
|
|
377
|
+
}
|
|
378
|
+
else if (entry.level < 7) {
|
|
379
|
+
yield entry;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else if (showCodeCells && entry.cell.cellKind === CellKind.Code) {
|
|
383
|
+
if (showCodeCellSymbols) {
|
|
384
|
+
yield entry;
|
|
385
|
+
}
|
|
386
|
+
else if (entry.level === 7) {
|
|
387
|
+
yield entry;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
237
392
|
async setFullSymbols(cancelToken) {
|
|
238
393
|
await this._outlineProvider?.setFullSymbols(cancelToken);
|
|
239
394
|
}
|
|
@@ -332,8 +487,12 @@ let NotebookOutlineCreator = class NotebookOutlineCreator {
|
|
|
332
487
|
}
|
|
333
488
|
async createOutline(editor, target, cancelToken) {
|
|
334
489
|
const outline = this._instantiationService.createInstance(NotebookCellOutline, editor, target);
|
|
335
|
-
const
|
|
336
|
-
|
|
490
|
+
const showAllGotoSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
|
|
491
|
+
const showAllOutlineSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
|
|
492
|
+
if (target === 4 && showAllGotoSymbols) {
|
|
493
|
+
await outline.setFullSymbols(cancelToken);
|
|
494
|
+
}
|
|
495
|
+
else if (target === 1 && showAllOutlineSymbols) {
|
|
337
496
|
await outline.setFullSymbols(cancelToken);
|
|
338
497
|
}
|
|
339
498
|
return outline;
|
|
@@ -344,28 +503,53 @@ NotebookOutlineCreator = ( __decorate([
|
|
|
344
503
|
( __param(1, IInstantiationService)),
|
|
345
504
|
( __param(2, IConfigurationService))
|
|
346
505
|
], NotebookOutlineCreator));
|
|
506
|
+
const NotebookOutlineContext = {
|
|
507
|
+
CellKind: ( new RawContextKey('notebookCellKind', undefined)),
|
|
508
|
+
CellHasChildren: ( new RawContextKey('notebookCellHasChildren', false)),
|
|
509
|
+
CellHasHeader: ( new RawContextKey('notebookCellHasHeader', false)),
|
|
510
|
+
CellFoldingState: ( new RawContextKey('notebookCellFoldingState', 0 )),
|
|
511
|
+
OutlineElementTarget: ( new RawContextKey('notebookOutlineElementTarget', undefined)),
|
|
512
|
+
};
|
|
347
513
|
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(NotebookOutlineCreator, 4 );
|
|
348
514
|
( Registry.as(Extensions$1.Configuration)).registerConfiguration({
|
|
349
515
|
id: 'notebook',
|
|
350
516
|
order: 100,
|
|
351
517
|
type: 'object',
|
|
352
518
|
'properties': {
|
|
353
|
-
|
|
519
|
+
[NotebookSetting.outlineShowMarkdownHeadersOnly]: {
|
|
520
|
+
type: 'boolean',
|
|
521
|
+
default: true,
|
|
522
|
+
markdownDescription: ( localizeWithPath(
|
|
523
|
+
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
524
|
+
'outline.showMarkdownHeadersOnly',
|
|
525
|
+
"When enabled, notebook outline will show only markdown cells containing a header."
|
|
526
|
+
))
|
|
527
|
+
},
|
|
528
|
+
[NotebookSetting.outlineShowCodeCells]: {
|
|
354
529
|
type: 'boolean',
|
|
355
530
|
default: false,
|
|
356
531
|
markdownDescription: ( localizeWithPath(
|
|
357
532
|
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
358
533
|
'outline.showCodeCells',
|
|
359
|
-
"When enabled notebook outline shows code cells."
|
|
534
|
+
"When enabled, notebook outline shows code cells."
|
|
535
|
+
))
|
|
536
|
+
},
|
|
537
|
+
[NotebookSetting.outlineShowCodeCellSymbols]: {
|
|
538
|
+
type: 'boolean',
|
|
539
|
+
default: true,
|
|
540
|
+
markdownDescription: ( localizeWithPath(
|
|
541
|
+
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
542
|
+
'outline.showCodeCellSymbols',
|
|
543
|
+
"When enabled, notebook outline shows code cell symbols. Relies on `notebook.outline.showCodeCells` being enabled."
|
|
360
544
|
))
|
|
361
545
|
},
|
|
362
|
-
|
|
546
|
+
[NotebookSetting.breadcrumbsShowCodeCells]: {
|
|
363
547
|
type: 'boolean',
|
|
364
548
|
default: true,
|
|
365
549
|
markdownDescription: ( localizeWithPath(
|
|
366
550
|
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
367
551
|
'breadcrumbs.showCodeCells',
|
|
368
|
-
"When enabled notebook breadcrumbs contain code cells."
|
|
552
|
+
"When enabled, notebook breadcrumbs contain code cells."
|
|
369
553
|
))
|
|
370
554
|
},
|
|
371
555
|
[NotebookSetting.gotoSymbolsAllSymbols]: {
|
|
@@ -374,10 +558,99 @@ NotebookOutlineCreator = ( __decorate([
|
|
|
374
558
|
markdownDescription: ( localizeWithPath(
|
|
375
559
|
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
376
560
|
'notebook.gotoSymbols.showAllSymbols',
|
|
377
|
-
"When enabled the Go to Symbol Quick Pick will display full code symbols from the notebook, as well as Markdown headers."
|
|
561
|
+
"When enabled, the Go to Symbol Quick Pick will display full code symbols from the notebook, as well as Markdown headers."
|
|
378
562
|
))
|
|
379
563
|
},
|
|
380
564
|
}
|
|
381
565
|
});
|
|
566
|
+
MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
|
|
567
|
+
submenu: MenuId.NotebookOutlineFilter,
|
|
568
|
+
title: ( localizeWithPath(
|
|
569
|
+
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
570
|
+
'filter',
|
|
571
|
+
"Filter Entries"
|
|
572
|
+
)),
|
|
573
|
+
icon: Codicon.filter,
|
|
574
|
+
group: 'navigation',
|
|
575
|
+
order: -1,
|
|
576
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', IOutlinePane.Id)), NOTEBOOK_IS_ACTIVE_EDITOR)),
|
|
577
|
+
});
|
|
578
|
+
registerAction2(class ToggleShowMarkdownHeadersOnly extends Action2 {
|
|
579
|
+
constructor() {
|
|
580
|
+
super({
|
|
581
|
+
id: 'notebook.outline.toggleShowMarkdownHeadersOnly',
|
|
582
|
+
title: ( localizeWithPath(
|
|
583
|
+
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
584
|
+
'toggleShowMarkdownHeadersOnly',
|
|
585
|
+
"Markdown Headers Only"
|
|
586
|
+
)),
|
|
587
|
+
f1: false,
|
|
588
|
+
toggled: {
|
|
589
|
+
condition: ( ContextKeyExpr.equals('config.notebook.outline.showMarkdownHeadersOnly', true))
|
|
590
|
+
},
|
|
591
|
+
menu: {
|
|
592
|
+
id: MenuId.NotebookOutlineFilter,
|
|
593
|
+
group: '0_markdown_cells',
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
run(accessor, ...args) {
|
|
598
|
+
const configurationService = accessor.get(IConfigurationService);
|
|
599
|
+
const showMarkdownHeadersOnly = configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly);
|
|
600
|
+
configurationService.updateValue(NotebookSetting.outlineShowMarkdownHeadersOnly, !showMarkdownHeadersOnly);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
registerAction2(class ToggleCodeCellEntries extends Action2 {
|
|
604
|
+
constructor() {
|
|
605
|
+
super({
|
|
606
|
+
id: 'notebook.outline.toggleCodeCells',
|
|
607
|
+
title: ( localizeWithPath(
|
|
608
|
+
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
609
|
+
'toggleCodeCells',
|
|
610
|
+
"Code Cells"
|
|
611
|
+
)),
|
|
612
|
+
f1: false,
|
|
613
|
+
toggled: {
|
|
614
|
+
condition: ( ContextKeyExpr.equals('config.notebook.outline.showCodeCells', true))
|
|
615
|
+
},
|
|
616
|
+
menu: {
|
|
617
|
+
id: MenuId.NotebookOutlineFilter,
|
|
618
|
+
order: 1,
|
|
619
|
+
group: '1_code_cells',
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
run(accessor, ...args) {
|
|
624
|
+
const configurationService = accessor.get(IConfigurationService);
|
|
625
|
+
const showCodeCells = configurationService.getValue(NotebookSetting.outlineShowCodeCells);
|
|
626
|
+
configurationService.updateValue(NotebookSetting.outlineShowCodeCells, !showCodeCells);
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
registerAction2(class ToggleCodeCellSymbolEntries extends Action2 {
|
|
630
|
+
constructor() {
|
|
631
|
+
super({
|
|
632
|
+
id: 'notebook.outline.toggleCodeCellSymbols',
|
|
633
|
+
title: ( localizeWithPath(
|
|
634
|
+
'vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline',
|
|
635
|
+
'toggleCodeCellSymbols',
|
|
636
|
+
"Code Cell Symbols"
|
|
637
|
+
)),
|
|
638
|
+
f1: false,
|
|
639
|
+
toggled: {
|
|
640
|
+
condition: ( ContextKeyExpr.equals('config.notebook.outline.showCodeCellSymbols', true))
|
|
641
|
+
},
|
|
642
|
+
menu: {
|
|
643
|
+
id: MenuId.NotebookOutlineFilter,
|
|
644
|
+
order: 2,
|
|
645
|
+
group: '1_code_cells',
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
run(accessor, ...args) {
|
|
650
|
+
const configurationService = accessor.get(IConfigurationService);
|
|
651
|
+
const showCodeCellSymbols = configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
|
|
652
|
+
configurationService.updateValue(NotebookSetting.outlineShowCodeCellSymbols, !showCodeCellSymbols);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
382
655
|
|
|
383
|
-
export { NotebookCellOutline, NotebookOutlineCreator };
|
|
656
|
+
export { NotebookCellOutline, NotebookOutlineContext, NotebookOutlineCreator };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import {
|
|
2
|
+
import { HierarchicalKind } from 'vscode/vscode/vs/base/common/hierarchicalKind';
|
|
3
3
|
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import { isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
5
5
|
import { ResourceTextEdit, IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
@@ -13,6 +13,7 @@ import { applyCodeAction, ApplyCodeActionReason, getCodeActions } from 'vscode/v
|
|
|
13
13
|
import { CodeActionKind, CodeActionTriggerSource } from 'vscode/vscode/vs/editor/contrib/codeAction/common/types';
|
|
14
14
|
import { getDocumentFormattingEditsUntilResult } from 'vscode/vscode/vs/editor/contrib/format/browser/format';
|
|
15
15
|
import { SnippetController2 } from 'vscode/vscode/vs/editor/contrib/snippet/browser/snippetController2';
|
|
16
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
16
17
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
17
18
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
19
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
@@ -91,11 +92,13 @@ let TrimWhitespaceParticipant = class TrimWhitespaceParticipant {
|
|
|
91
92
|
this.bulkEditService = bulkEditService;
|
|
92
93
|
}
|
|
93
94
|
async participate(workingCopy, context, progress, _token) {
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
const trimTrailingWhitespaceOption = this.configurationService.getValue('files.trimTrailingWhitespace');
|
|
96
|
+
const trimInRegexAndStrings = this.configurationService.getValue('files.trimTrailingWhitespaceInRegexAndStrings');
|
|
97
|
+
if (trimTrailingWhitespaceOption) {
|
|
98
|
+
await this.doTrimTrailingWhitespace(workingCopy, context.reason === 2 , trimInRegexAndStrings, progress);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
|
-
async doTrimTrailingWhitespace(workingCopy, isAutoSaved, progress) {
|
|
101
|
+
async doTrimTrailingWhitespace(workingCopy, isAutoSaved, trimInRegexesAndStrings, progress) {
|
|
99
102
|
if (!workingCopy.model || !(workingCopy.model instanceof NotebookFileWorkingCopyModel)) {
|
|
100
103
|
return;
|
|
101
104
|
}
|
|
@@ -125,7 +128,7 @@ let TrimWhitespaceParticipant = class TrimWhitespaceParticipant {
|
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
|
-
const ops = trimTrailingWhitespace(model, cursors);
|
|
131
|
+
const ops = trimTrailingWhitespace(model, cursors, trimInRegexesAndStrings);
|
|
129
132
|
if (!ops.length) {
|
|
130
133
|
return [];
|
|
131
134
|
}
|
|
@@ -193,6 +196,9 @@ let TrimFinalNewLinesParticipant = class TrimFinalNewLinesParticipant {
|
|
|
193
196
|
const textBuffer = cell.textBuffer;
|
|
194
197
|
const lastNonEmptyLine = this.findLastNonEmptyLine(textBuffer);
|
|
195
198
|
const deleteFromLineNumber = Math.max(lastNonEmptyLine + 1, cannotTouchLineNumber + 1);
|
|
199
|
+
if (deleteFromLineNumber > textBuffer.getLineCount()) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
196
202
|
const deletionRange = ( new Range(
|
|
197
203
|
deleteFromLineNumber,
|
|
198
204
|
1,
|
|
@@ -226,7 +232,7 @@ TrimFinalNewLinesParticipant = ( __decorate([
|
|
|
226
232
|
( __param(1, IEditorService)),
|
|
227
233
|
( __param(2, IBulkEditService))
|
|
228
234
|
], TrimFinalNewLinesParticipant));
|
|
229
|
-
let
|
|
235
|
+
let InsertFinalNewLineParticipant = class InsertFinalNewLineParticipant {
|
|
230
236
|
constructor(configurationService, bulkEditService, editorService) {
|
|
231
237
|
this.configurationService = configurationService;
|
|
232
238
|
this.bulkEditService = bulkEditService;
|
|
@@ -281,11 +287,11 @@ let FinalNewLineParticipant = class FinalNewLineParticipant {
|
|
|
281
287
|
}
|
|
282
288
|
}
|
|
283
289
|
};
|
|
284
|
-
|
|
290
|
+
InsertFinalNewLineParticipant = ( __decorate([
|
|
285
291
|
( __param(0, IConfigurationService)),
|
|
286
292
|
( __param(1, IBulkEditService)),
|
|
287
293
|
( __param(2, IEditorService))
|
|
288
|
-
],
|
|
294
|
+
], InsertFinalNewLineParticipant));
|
|
289
295
|
let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
290
296
|
constructor(configurationService, logService, workspaceTrustManagementService, languageFeaturesService, textModelService, instantiationService) {
|
|
291
297
|
this.configurationService = configurationService;
|
|
@@ -391,7 +397,7 @@ let CodeActionOnSaveParticipant = class CodeActionOnSaveParticipant {
|
|
|
391
397
|
}
|
|
392
398
|
}
|
|
393
399
|
createCodeActionsOnSave(settingItems) {
|
|
394
|
-
const kinds = ( settingItems.map(x => ( new
|
|
400
|
+
const kinds = ( settingItems.map(x => ( new HierarchicalKind(x))));
|
|
395
401
|
return kinds.filter(kind => {
|
|
396
402
|
return kinds.every(otherKind => otherKind.equals(kind) || !otherKind.contains(kind));
|
|
397
403
|
});
|
|
@@ -497,7 +503,7 @@ let SaveParticipantsContribution = class SaveParticipantsContribution extends Di
|
|
|
497
503
|
this._register(this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(TrimWhitespaceParticipant)));
|
|
498
504
|
this._register(this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(CodeActionOnSaveParticipant)));
|
|
499
505
|
this._register(this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(FormatOnSaveParticipant)));
|
|
500
|
-
this._register(this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(
|
|
506
|
+
this._register(this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(InsertFinalNewLineParticipant)));
|
|
501
507
|
this._register(this.workingCopyFileService.addSaveParticipant(this.instantiationService.createInstance(TrimFinalNewLinesParticipant)));
|
|
502
508
|
}
|
|
503
509
|
};
|