@codingame/monaco-vscode-notebook-service-override 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/notebook.js +12 -12
  4. package/override/vs/platform/dialogs/common/dialogs.js +10 -0
  5. package/package.json +2 -2
  6. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
  7. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +391 -0
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +544 -0
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +320 -0
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +84 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +101 -0
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +393 -0
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +5 -0
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +97 -0
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +120 -0
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +60 -0
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +150 -0
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +656 -0
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +77 -0
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +517 -0
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +159 -0
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +56 -0
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +652 -0
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +721 -0
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +351 -0
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +315 -0
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +199 -0
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +47 -0
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +115 -0
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +911 -0
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +395 -0
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +185 -0
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1187 -0
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +451 -0
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +192 -0
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +510 -0
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +130 -0
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +341 -0
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +641 -0
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
  67. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +90 -0
  68. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1002 -0
  69. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
  70. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +203 -0
  71. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
  73. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
  74. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +386 -0
  75. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +408 -0
  76. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
  77. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
@@ -0,0 +1,72 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { throttle } from 'vscode/vscode/vs/base/common/decorators';
3
+ import { Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
5
+ import { NotebookCellExecutionState } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
6
+ import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
7
+ import { IUserActivityService } from 'vscode/vscode/vs/workbench/services/userActivity/common/userActivityService';
8
+
9
+ let ExecutionEditorProgressController = class ExecutionEditorProgressController extends Disposable {
10
+ static { this.id = 'workbench.notebook.executionEditorProgress'; }
11
+ constructor(_notebookEditor, _notebookExecutionStateService, _userActivity) {
12
+ super();
13
+ this._notebookEditor = _notebookEditor;
14
+ this._notebookExecutionStateService = _notebookExecutionStateService;
15
+ this._userActivity = _userActivity;
16
+ this._activityMutex = this._register(( new MutableDisposable()));
17
+ this._register(_notebookEditor.onDidScroll(() => this._update()));
18
+ this._register(_notebookExecutionStateService.onDidChangeExecution(e => {
19
+ if (( e.notebook.toString()) !== this._notebookEditor.textModel?.uri.toString()) {
20
+ return;
21
+ }
22
+ this._update();
23
+ }));
24
+ this._register(_notebookEditor.onDidChangeModel(() => this._update()));
25
+ }
26
+ _update() {
27
+ if (!this._notebookEditor.hasModel()) {
28
+ return;
29
+ }
30
+ const cellExecutions = this._notebookExecutionStateService.getCellExecutionsForNotebook(this._notebookEditor.textModel?.uri)
31
+ .filter(exe => exe.state === NotebookCellExecutionState.Executing);
32
+ const notebookExecution = this._notebookExecutionStateService.getExecution(this._notebookEditor.textModel?.uri);
33
+ const executionIsVisible = (exe) => {
34
+ for (const range of this._notebookEditor.visibleRanges) {
35
+ for (const cell of this._notebookEditor.getCellsInRange(range)) {
36
+ if (cell.handle === exe.cellHandle) {
37
+ const top = this._notebookEditor.getAbsoluteTopOfElement(cell);
38
+ if (this._notebookEditor.scrollTop < top + 5) {
39
+ return true;
40
+ }
41
+ }
42
+ }
43
+ }
44
+ return false;
45
+ };
46
+ const hasAnyExecution = cellExecutions.length || notebookExecution;
47
+ if (hasAnyExecution && !this._activityMutex.value) {
48
+ this._activityMutex.value = this._userActivity.markActive();
49
+ }
50
+ else if (!hasAnyExecution && this._activityMutex.value) {
51
+ this._activityMutex.clear();
52
+ }
53
+ const shouldShowEditorProgressbarForCellExecutions = cellExecutions.length && !( cellExecutions.some(executionIsVisible)) && !( cellExecutions.some(e => e.isPaused));
54
+ const showEditorProgressBar = !!notebookExecution || shouldShowEditorProgressbarForCellExecutions;
55
+ if (showEditorProgressBar) {
56
+ this._notebookEditor.showProgress();
57
+ }
58
+ else {
59
+ this._notebookEditor.hideProgress();
60
+ }
61
+ }
62
+ };
63
+ ExecutionEditorProgressController.__decorator = ( __decorate([
64
+ throttle(100)
65
+ ], ExecutionEditorProgressController.prototype, "_update", null));
66
+ ExecutionEditorProgressController = ( __decorate([
67
+ ( __param(1, INotebookExecutionStateService)),
68
+ ( __param(2, IUserActivityService))
69
+ ], ExecutionEditorProgressController));
70
+ registerNotebookContribution(ExecutionEditorProgressController.id, ExecutionEditorProgressController);
71
+
72
+ export { ExecutionEditorProgressController };
@@ -0,0 +1,6 @@
1
+ import n from '../../../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
+
3
+ var css = ".monaco-workbench .notebookOverlay.notebook-editor.find-hide-transition,.monaco-workbench .notebookOverlay.notebook-editor.find-show-transition{overflow-y:hidden}.monaco-workbench .notebookOverlay.notebook-editor .simple-fr-find-part-wrapper .matchesCount{box-sizing:border-box;overflow:hidden;padding:0 2px;text-align:center;text-overflow:ellipsis;white-space:nowrap}";
4
+ n(css,{});
5
+
6
+ export { css, css as default };
@@ -0,0 +1,168 @@
1
+ import './media/notebookFind.css.js';
2
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
3
+ import { isEqual } from 'vscode/vscode/vs/base/common/resources';
4
+ import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
5
+ import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
6
+ import { StartFindAction, StartFindReplaceAction, getSelectionSearchString } from 'vscode/vscode/vs/editor/contrib/find/browser/findController';
7
+ import { localize2WithPath } from 'vscode/vscode/vs/nls';
8
+ import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
9
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
10
+ import { NotebookFindContrib } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget';
11
+ import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
12
+ import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
13
+ import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
14
+ import { NOTEBOOK_EDITOR_FOCUSED, KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR, INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
15
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
16
+
17
+ registerNotebookContribution(NotebookFindContrib.id, NotebookFindContrib);
18
+ registerAction2(class extends Action2 {
19
+ constructor() {
20
+ super({
21
+ id: 'notebook.hideFind',
22
+ title: ( localize2WithPath(
23
+ 'vs/workbench/contrib/notebook/browser/contrib/find/notebookFind',
24
+ 'notebookActions.hideFind',
25
+ 'Hide Find in Notebook'
26
+ )),
27
+ keybinding: {
28
+ when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED)),
29
+ primary: 9 ,
30
+ weight: 200
31
+ }
32
+ });
33
+ }
34
+ async run(accessor) {
35
+ const editorService = accessor.get(IEditorService);
36
+ const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
37
+ if (!editor) {
38
+ return;
39
+ }
40
+ const controller = editor.getContribution(NotebookFindContrib.id);
41
+ controller.hide();
42
+ editor.focus();
43
+ }
44
+ });
45
+ registerAction2(class extends Action2 {
46
+ constructor() {
47
+ super({
48
+ id: 'notebook.find',
49
+ title: ( localize2WithPath(
50
+ 'vs/workbench/contrib/notebook/browser/contrib/find/notebookFind',
51
+ 'notebookActions.findInNotebook',
52
+ 'Find in Notebook'
53
+ )),
54
+ keybinding: {
55
+ when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( ContextKeyExpr.or(NOTEBOOK_IS_ACTIVE_EDITOR, INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR)), ( EditorContextKeys.focus.toNegated()))),
56
+ primary: 36 | 2048 ,
57
+ weight: 200
58
+ }
59
+ });
60
+ }
61
+ async run(accessor) {
62
+ const editorService = accessor.get(IEditorService);
63
+ const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
64
+ if (!editor) {
65
+ return;
66
+ }
67
+ const controller = editor.getContribution(NotebookFindContrib.id);
68
+ controller.show();
69
+ }
70
+ });
71
+ function notebookContainsTextModel(uri, textModel) {
72
+ if (textModel.uri.scheme === Schemas.vscodeNotebookCell) {
73
+ const cellUri = CellUri.parse(textModel.uri);
74
+ if (cellUri && isEqual(cellUri.notebook, uri)) {
75
+ return true;
76
+ }
77
+ }
78
+ return false;
79
+ }
80
+ function getSearchStringOptions(editor, opts) {
81
+ if (opts.seedSearchStringFromSelection === 'single') {
82
+ const selectionSearchString = getSelectionSearchString(editor, opts.seedSearchStringFromSelection, opts.seedSearchStringFromNonEmptySelection);
83
+ if (selectionSearchString) {
84
+ return {
85
+ searchString: selectionSearchString,
86
+ selection: editor.getSelection()
87
+ };
88
+ }
89
+ }
90
+ else if (opts.seedSearchStringFromSelection === 'multiple' && !opts.updateSearchScope) {
91
+ const selectionSearchString = getSelectionSearchString(editor, opts.seedSearchStringFromSelection);
92
+ if (selectionSearchString) {
93
+ return {
94
+ searchString: selectionSearchString,
95
+ selection: editor.getSelection()
96
+ };
97
+ }
98
+ }
99
+ return undefined;
100
+ }
101
+ StartFindAction.addImplementation(100, (accessor, codeEditor, args) => {
102
+ const editorService = accessor.get(IEditorService);
103
+ const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
104
+ if (!editor) {
105
+ return false;
106
+ }
107
+ if (!codeEditor.hasModel()) {
108
+ return false;
109
+ }
110
+ if (!editor.hasEditorFocus() && !editor.hasWebviewFocus()) {
111
+ const codeEditorService = accessor.get(ICodeEditorService);
112
+ const textEditor = codeEditorService.getFocusedCodeEditor() || codeEditorService.getActiveCodeEditor();
113
+ if (editor.hasModel() && textEditor && textEditor.hasModel() && notebookContainsTextModel(editor.textModel.uri, textEditor.getModel())) ;
114
+ else {
115
+ return false;
116
+ }
117
+ }
118
+ const controller = editor.getContribution(NotebookFindContrib.id);
119
+ const searchStringOptions = getSearchStringOptions(codeEditor, {
120
+ forceRevealReplace: false,
121
+ seedSearchStringFromSelection: codeEditor.getOption(41 ).seedSearchStringFromSelection !== 'never' ? 'single' : 'none',
122
+ seedSearchStringFromNonEmptySelection: codeEditor.getOption(41 ).seedSearchStringFromSelection === 'selection',
123
+ seedSearchStringFromGlobalClipboard: codeEditor.getOption(41 ).globalFindClipboard,
124
+ shouldFocus: 1 ,
125
+ shouldAnimate: true,
126
+ updateSearchScope: false,
127
+ loop: codeEditor.getOption(41 ).loop
128
+ });
129
+ let options = undefined;
130
+ const uri = codeEditor.getModel().uri;
131
+ const data = CellUri.parse(uri);
132
+ if (searchStringOptions?.selection && data) {
133
+ const cell = editor.getCellByHandle(data.handle);
134
+ if (cell) {
135
+ options = {
136
+ searchStringSeededFrom: { cell, range: searchStringOptions.selection },
137
+ };
138
+ }
139
+ }
140
+ controller.show(searchStringOptions?.searchString, options);
141
+ return true;
142
+ });
143
+ StartFindReplaceAction.addImplementation(100, (accessor, codeEditor, args) => {
144
+ const editorService = accessor.get(IEditorService);
145
+ const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
146
+ if (!editor) {
147
+ return false;
148
+ }
149
+ if (!codeEditor.hasModel()) {
150
+ return false;
151
+ }
152
+ const controller = editor.getContribution(NotebookFindContrib.id);
153
+ const searchStringOptions = getSearchStringOptions(codeEditor, {
154
+ forceRevealReplace: false,
155
+ seedSearchStringFromSelection: codeEditor.getOption(41 ).seedSearchStringFromSelection !== 'never' ? 'single' : 'none',
156
+ seedSearchStringFromNonEmptySelection: codeEditor.getOption(41 ).seedSearchStringFromSelection === 'selection',
157
+ seedSearchStringFromGlobalClipboard: codeEditor.getOption(41 ).globalFindClipboard,
158
+ shouldFocus: 1 ,
159
+ shouldAnimate: true,
160
+ updateSearchScope: false,
161
+ loop: codeEditor.getOption(41 ).loop
162
+ });
163
+ if (controller) {
164
+ controller.replace(searchStringOptions?.searchString);
165
+ return true;
166
+ }
167
+ return false;
168
+ });
@@ -0,0 +1,209 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
4
+ import { DisposableStore, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { registerEditorAction, EditorAction } from 'vscode/vscode/vs/editor/browser/editorExtensions';
6
+ import { IBulkEditService, ResourceTextEdit } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
7
+ import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
8
+ import { IEditorWorkerService } from 'vscode/vscode/vs/editor/common/services/editorWorker';
9
+ import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
10
+ import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
11
+ import { getDocumentFormattingEditsUntilResult, formatDocumentWithSelectedProvider } from 'vscode/vscode/vs/editor/contrib/format/browser/format';
12
+ import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
13
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
14
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
15
+ import { Progress } from 'vscode/vscode/vs/platform/progress/common/progress';
16
+ import { NOTEBOOK_ACTIONS_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
17
+ import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
18
+ import { NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_EDITOR_EDITABLE } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
19
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
20
+ import { INotebookExecutionService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionService';
21
+ import { NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
22
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
23
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
24
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
25
+ import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
26
+
27
+ registerAction2(class extends Action2 {
28
+ constructor() {
29
+ super({
30
+ id: 'notebook.format',
31
+ title: ( localize2WithPath(
32
+ 'vs/workbench/contrib/notebook/browser/contrib/format/formatting',
33
+ 'format.title',
34
+ 'Format Notebook'
35
+ )),
36
+ category: NOTEBOOK_ACTIONS_CATEGORY,
37
+ precondition: ( ContextKeyExpr.and(NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_EDITOR_EDITABLE)),
38
+ keybinding: {
39
+ when: ( EditorContextKeys.editorTextFocus.toNegated()),
40
+ primary: 1024 | 512 | 36 ,
41
+ linux: { primary: 2048 | 1024 | 39 },
42
+ weight: 200
43
+ },
44
+ f1: true,
45
+ menu: {
46
+ id: MenuId.EditorContext,
47
+ when: ( ContextKeyExpr.and(
48
+ EditorContextKeys.inCompositeEditor,
49
+ EditorContextKeys.hasDocumentFormattingProvider
50
+ )),
51
+ group: '1_modification',
52
+ order: 1.3
53
+ }
54
+ });
55
+ }
56
+ async run(accessor) {
57
+ const editorService = accessor.get(IEditorService);
58
+ const textModelService = accessor.get(ITextModelService);
59
+ const editorWorkerService = accessor.get(IEditorWorkerService);
60
+ const languageFeaturesService = accessor.get(ILanguageFeaturesService);
61
+ const bulkEditService = accessor.get(IBulkEditService);
62
+ const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
63
+ if (!editor || !editor.hasModel()) {
64
+ return;
65
+ }
66
+ const notebook = editor.textModel;
67
+ const disposable = ( new DisposableStore());
68
+ try {
69
+ const allCellEdits = await Promise.all(( notebook.cells.map(async (cell) => {
70
+ const ref = await textModelService.createModelReference(cell.uri);
71
+ disposable.add(ref);
72
+ const model = ref.object.textEditorModel;
73
+ const formatEdits = await getDocumentFormattingEditsUntilResult(editorWorkerService, languageFeaturesService, model, model.getOptions(), CancellationToken.None);
74
+ const edits = [];
75
+ if (formatEdits) {
76
+ for (const edit of formatEdits) {
77
+ edits.push(( new ResourceTextEdit(model.uri, edit, model.getVersionId())));
78
+ }
79
+ return edits;
80
+ }
81
+ return [];
82
+ })));
83
+ await bulkEditService.apply( allCellEdits.flat(), { label: ( localizeWithPath(
84
+ 'vs/workbench/contrib/notebook/browser/contrib/format/formatting',
85
+ 'label',
86
+ "Format Notebook"
87
+ )), code: 'undoredo.formatNotebook', });
88
+ }
89
+ finally {
90
+ disposable.dispose();
91
+ }
92
+ }
93
+ });
94
+ registerEditorAction(class FormatCellAction extends EditorAction {
95
+ constructor() {
96
+ super({
97
+ id: 'notebook.formatCell',
98
+ label: ( localizeWithPath(
99
+ 'vs/workbench/contrib/notebook/browser/contrib/format/formatting',
100
+ 'formatCell.label',
101
+ "Format Cell"
102
+ )),
103
+ alias: 'Format Cell',
104
+ precondition: ( ContextKeyExpr.and(
105
+ NOTEBOOK_IS_ACTIVE_EDITOR,
106
+ NOTEBOOK_EDITOR_EDITABLE,
107
+ EditorContextKeys.inCompositeEditor,
108
+ EditorContextKeys.writable,
109
+ EditorContextKeys.hasDocumentFormattingProvider
110
+ )),
111
+ kbOpts: {
112
+ kbExpr: ( ContextKeyExpr.and(EditorContextKeys.editorTextFocus)),
113
+ primary: 1024 | 512 | 36 ,
114
+ linux: { primary: 2048 | 1024 | 39 },
115
+ weight: 100
116
+ },
117
+ contextMenuOpts: {
118
+ group: '1_modification',
119
+ order: 1.301
120
+ }
121
+ });
122
+ }
123
+ async run(accessor, editor) {
124
+ if (editor.hasModel()) {
125
+ const instaService = accessor.get(IInstantiationService);
126
+ await instaService.invokeFunction(formatDocumentWithSelectedProvider, editor, 1 , Progress.None, CancellationToken.None, true);
127
+ }
128
+ }
129
+ });
130
+ let FormatOnCellExecutionParticipant = class FormatOnCellExecutionParticipant {
131
+ constructor(bulkEditService, languageFeaturesService, textModelService, editorWorkerService, configurationService, _notebookService) {
132
+ this.bulkEditService = bulkEditService;
133
+ this.languageFeaturesService = languageFeaturesService;
134
+ this.textModelService = textModelService;
135
+ this.editorWorkerService = editorWorkerService;
136
+ this.configurationService = configurationService;
137
+ this._notebookService = _notebookService;
138
+ }
139
+ async onWillExecuteCell(executions) {
140
+ const enabled = this.configurationService.getValue(NotebookSetting.formatOnCellExecution);
141
+ if (!enabled) {
142
+ return;
143
+ }
144
+ const disposable = ( new DisposableStore());
145
+ try {
146
+ const allCellEdits = await Promise.all(( executions.map(async (cellExecution) => {
147
+ const nbModel = this._notebookService.getNotebookTextModel(cellExecution.notebook);
148
+ if (!nbModel) {
149
+ return [];
150
+ }
151
+ let activeCell;
152
+ for (const cell of nbModel.cells) {
153
+ if (cell.handle === cellExecution.cellHandle) {
154
+ activeCell = cell;
155
+ break;
156
+ }
157
+ }
158
+ if (!activeCell) {
159
+ return [];
160
+ }
161
+ const ref = await this.textModelService.createModelReference(activeCell.uri);
162
+ disposable.add(ref);
163
+ const model = ref.object.textEditorModel;
164
+ const formatEdits = await getDocumentFormattingEditsUntilResult(this.editorWorkerService, this.languageFeaturesService, model, model.getOptions(), CancellationToken.None);
165
+ const edits = [];
166
+ if (formatEdits) {
167
+ edits.push(...( formatEdits.map(edit => ( new ResourceTextEdit(model.uri, edit, model.getVersionId())))));
168
+ return edits;
169
+ }
170
+ return [];
171
+ })));
172
+ await this.bulkEditService.apply( allCellEdits.flat(), { label: ( localizeWithPath(
173
+ 'vs/workbench/contrib/notebook/browser/contrib/format/formatting',
174
+ 'formatCells.label',
175
+ "Format Cells"
176
+ )), code: 'undoredo.notebooks.onWillExecuteFormat', });
177
+ }
178
+ finally {
179
+ disposable.dispose();
180
+ }
181
+ }
182
+ };
183
+ FormatOnCellExecutionParticipant = ( __decorate([
184
+ ( __param(0, IBulkEditService)),
185
+ ( __param(1, ILanguageFeaturesService)),
186
+ ( __param(2, ITextModelService)),
187
+ ( __param(3, IEditorWorkerService)),
188
+ ( __param(4, IConfigurationService)),
189
+ ( __param(5, INotebookService))
190
+ ], FormatOnCellExecutionParticipant));
191
+ let CellExecutionParticipantsContribution = class CellExecutionParticipantsContribution extends Disposable {
192
+ constructor(instantiationService, notebookExecutionService) {
193
+ super();
194
+ this.instantiationService = instantiationService;
195
+ this.notebookExecutionService = notebookExecutionService;
196
+ this.registerKernelExecutionParticipants();
197
+ }
198
+ registerKernelExecutionParticipants() {
199
+ this._register(this.notebookExecutionService.registerExecutionParticipant(this.instantiationService.createInstance(FormatOnCellExecutionParticipant)));
200
+ }
201
+ };
202
+ CellExecutionParticipantsContribution = ( __decorate([
203
+ ( __param(0, IInstantiationService)),
204
+ ( __param(1, INotebookExecutionService))
205
+ ], CellExecutionParticipantsContribution));
206
+ const workbenchContributionsRegistry = ( Registry.as(Extensions.Workbench));
207
+ workbenchContributionsRegistry.registerWorkbenchContribution(CellExecutionParticipantsContribution, 3 );
208
+
209
+ export { CellExecutionParticipantsContribution };
@@ -0,0 +1,84 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import { localize2WithPath } from 'vscode/vscode/vs/nls';
4
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
5
+ import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
6
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
7
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
8
+ import { ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
9
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
10
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
11
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
12
+ import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
13
+ import { NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
14
+ import { HAS_OPENED_NOTEBOOK } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
15
+ import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
16
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
17
+
18
+ const hasOpenedNotebookKey = 'hasOpenedNotebook';
19
+ const hasShownGettingStartedKey = 'hasShownNotebookGettingStarted';
20
+ let NotebookGettingStarted = class NotebookGettingStarted extends Disposable {
21
+ constructor(_editorService, _storageService, _contextKeyService, _commandService, _configurationService) {
22
+ super();
23
+ const hasOpenedNotebook = HAS_OPENED_NOTEBOOK.bindTo(_contextKeyService);
24
+ const memento = ( new Memento('notebookGettingStarted2', _storageService));
25
+ const storedValue = memento.getMemento(0 , 0 );
26
+ if (storedValue[hasOpenedNotebookKey]) {
27
+ hasOpenedNotebook.set(true);
28
+ }
29
+ const needToShowGettingStarted = _configurationService.getValue(NotebookSetting.openGettingStarted) && !storedValue[hasShownGettingStartedKey];
30
+ if (!storedValue[hasOpenedNotebookKey] || needToShowGettingStarted) {
31
+ const onDidOpenNotebook = () => {
32
+ hasOpenedNotebook.set(true);
33
+ storedValue[hasOpenedNotebookKey] = true;
34
+ if (needToShowGettingStarted) {
35
+ _commandService.executeCommand('workbench.action.openWalkthrough', { category: 'notebooks', step: 'notebookProfile' }, true);
36
+ storedValue[hasShownGettingStartedKey] = true;
37
+ }
38
+ memento.saveMemento();
39
+ };
40
+ if (_editorService.activeEditor?.typeId === NotebookEditorInput.ID) {
41
+ onDidOpenNotebook();
42
+ return;
43
+ }
44
+ const listener = this._register(_editorService.onDidActiveEditorChange(() => {
45
+ if (_editorService.activeEditor?.typeId === NotebookEditorInput.ID) {
46
+ listener.dispose();
47
+ onDidOpenNotebook();
48
+ }
49
+ }));
50
+ }
51
+ }
52
+ };
53
+ NotebookGettingStarted = ( __decorate([
54
+ ( __param(0, IEditorService)),
55
+ ( __param(1, IStorageService)),
56
+ ( __param(2, IContextKeyService)),
57
+ ( __param(3, ICommandService)),
58
+ ( __param(4, IConfigurationService))
59
+ ], NotebookGettingStarted));
60
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(NotebookGettingStarted, 3 );
61
+ registerAction2(class NotebookClearNotebookLayoutAction extends Action2 {
62
+ constructor() {
63
+ super({
64
+ id: 'workbench.notebook.layout.gettingStarted',
65
+ title: ( localize2WithPath(
66
+ 'vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted',
67
+ 'workbench.notebook.layout.gettingStarted.label',
68
+ "Reset notebook getting started"
69
+ )),
70
+ f1: true,
71
+ precondition: ( ContextKeyExpr.equals(`config.${NotebookSetting.openGettingStarted}`, true)),
72
+ category: Categories.Developer,
73
+ });
74
+ }
75
+ run(accessor) {
76
+ const storageService = accessor.get(IStorageService);
77
+ const memento = ( new Memento('notebookGettingStarted', storageService));
78
+ const storedValue = memento.getMemento(0 , 0 );
79
+ storedValue[hasOpenedNotebookKey] = undefined;
80
+ memento.saveMemento();
81
+ }
82
+ });
83
+
84
+ export { NotebookGettingStarted };
@@ -0,0 +1,82 @@
1
+ import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
4
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
5
+ import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService';
6
+ import { INotebookLoggingService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookLoggingService';
7
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
8
+
9
+ let NotebookKernelDetection = class NotebookKernelDetection extends Disposable {
10
+ constructor(_notebookKernelService, _extensionService, _notebookLoggingService) {
11
+ super();
12
+ this._notebookKernelService = _notebookKernelService;
13
+ this._extensionService = _extensionService;
14
+ this._notebookLoggingService = _notebookLoggingService;
15
+ this._detectionMap = ( new Map());
16
+ this._localDisposableStore = this._register(( new DisposableStore()));
17
+ this._registerListeners();
18
+ }
19
+ _registerListeners() {
20
+ this._localDisposableStore.clear();
21
+ this._localDisposableStore.add(this._extensionService.onWillActivateByEvent(e => {
22
+ if (e.event.startsWith('onNotebook:')) {
23
+ if (this._extensionService.activationEventIsDone(e.event)) {
24
+ return;
25
+ }
26
+ const notebookType = e.event.substring('onNotebook:'.length);
27
+ if (notebookType === '*') {
28
+ return;
29
+ }
30
+ let shouldStartDetection = false;
31
+ const extensionStatus = this._extensionService.getExtensionsStatus();
32
+ this._extensionService.extensions.forEach(extension => {
33
+ if (extensionStatus[extension.identifier.value].activationTimes) {
34
+ return;
35
+ }
36
+ if (extension.activationEvents?.includes(e.event)) {
37
+ shouldStartDetection = true;
38
+ }
39
+ });
40
+ if (shouldStartDetection && !( this._detectionMap.has(notebookType))) {
41
+ this._notebookLoggingService.debug('KernelDetection', `start extension activation for ${notebookType}`);
42
+ const task = this._notebookKernelService.registerNotebookKernelDetectionTask({
43
+ notebookType: notebookType
44
+ });
45
+ this._detectionMap.set(notebookType, task);
46
+ }
47
+ }
48
+ }));
49
+ let timer = null;
50
+ this._localDisposableStore.add(this._extensionService.onDidChangeExtensionsStatus(() => {
51
+ if (timer) {
52
+ clearTimeout(timer);
53
+ }
54
+ timer = setTimeout(() => {
55
+ const taskToDelete = [];
56
+ for (const [notebookType, task] of this._detectionMap) {
57
+ if (this._extensionService.activationEventIsDone(`onNotebook:${notebookType}`)) {
58
+ this._notebookLoggingService.debug('KernelDetection', `finish extension activation for ${notebookType}`);
59
+ taskToDelete.push(notebookType);
60
+ task.dispose();
61
+ }
62
+ }
63
+ taskToDelete.forEach(notebookType => {
64
+ this._detectionMap.delete(notebookType);
65
+ });
66
+ });
67
+ }));
68
+ this._localDisposableStore.add({
69
+ dispose: () => {
70
+ if (timer) {
71
+ clearTimeout(timer);
72
+ }
73
+ }
74
+ });
75
+ }
76
+ };
77
+ NotebookKernelDetection = ( __decorate([
78
+ ( __param(0, INotebookKernelService)),
79
+ ( __param(1, IExtensionService)),
80
+ ( __param(2, INotebookLoggingService))
81
+ ], NotebookKernelDetection));
82
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(NotebookKernelDetection, 3 );