@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.
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/notebook.js +12 -12
- package/override/vs/platform/dialogs/common/dialogs.js +10 -0
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +391 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +544 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +320 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +84 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +393 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +5 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +60 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +150 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +656 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +77 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +517 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +159 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +56 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +721 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +351 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +315 -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 +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +115 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +911 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +395 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +185 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1187 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +451 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +192 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +510 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +130 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +641 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +90 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1002 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +203 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +386 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +408 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { localize2WithPath } from 'vscode/vscode/vs/nls';
|
|
2
|
+
import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
3
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
4
|
+
import { NOTEBOOK_ACTIONS_CATEGORY } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
5
|
+
import { NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
6
|
+
|
|
7
|
+
const TOGGLE_CELL_TOOLBAR_POSITION = 'notebook.toggleCellToolbarPosition';
|
|
8
|
+
class ToggleCellToolbarPositionAction extends Action2 {
|
|
9
|
+
constructor() {
|
|
10
|
+
super({
|
|
11
|
+
id: TOGGLE_CELL_TOOLBAR_POSITION,
|
|
12
|
+
title: ( localize2WithPath(
|
|
13
|
+
'vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions',
|
|
14
|
+
'notebook.toggleCellToolbarPosition',
|
|
15
|
+
'Toggle Cell Toolbar Position'
|
|
16
|
+
)),
|
|
17
|
+
menu: [{
|
|
18
|
+
id: MenuId.NotebookCellTitle,
|
|
19
|
+
group: 'View',
|
|
20
|
+
order: 1
|
|
21
|
+
}],
|
|
22
|
+
category: NOTEBOOK_ACTIONS_CATEGORY,
|
|
23
|
+
f1: false
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async run(accessor, context) {
|
|
27
|
+
const editor = context && context.ui ? context.notebookEditor : undefined;
|
|
28
|
+
if (editor && editor.hasModel()) {
|
|
29
|
+
const viewType = editor.textModel.viewType;
|
|
30
|
+
const configurationService = accessor.get(IConfigurationService);
|
|
31
|
+
const toolbarPosition = configurationService.getValue(NotebookSetting.cellToolbarLocation);
|
|
32
|
+
const newConfig = this.togglePosition(viewType, toolbarPosition);
|
|
33
|
+
await configurationService.updateValue(NotebookSetting.cellToolbarLocation, newConfig);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
togglePosition(viewType, toolbarPosition) {
|
|
37
|
+
if (typeof toolbarPosition === 'string') {
|
|
38
|
+
if (['left', 'right', 'hidden'].indexOf(toolbarPosition) >= 0) {
|
|
39
|
+
const newViewValue = toolbarPosition === 'right' ? 'left' : 'right';
|
|
40
|
+
const config = {
|
|
41
|
+
default: toolbarPosition
|
|
42
|
+
};
|
|
43
|
+
config[viewType] = newViewValue;
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const config = {
|
|
48
|
+
default: 'right',
|
|
49
|
+
};
|
|
50
|
+
config[viewType] = 'left';
|
|
51
|
+
return config;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const oldValue = toolbarPosition[viewType] ?? toolbarPosition['default'] ?? 'right';
|
|
56
|
+
const newViewValue = oldValue === 'right' ? 'left' : 'right';
|
|
57
|
+
const newConfig = {
|
|
58
|
+
...toolbarPosition
|
|
59
|
+
};
|
|
60
|
+
newConfig[viewType] = newViewValue;
|
|
61
|
+
return newConfig;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
registerAction2(ToggleCellToolbarPositionAction);
|
|
66
|
+
|
|
67
|
+
export { ToggleCellToolbarPositionAction };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
3
|
+
import { MarkerList, IMarkerNavigationService } from 'vscode/vscode/vs/editor/contrib/gotoError/browser/markerNavigationService';
|
|
4
|
+
import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
5
|
+
import { MarkerSeverity, IMarkerService } from 'vscode/vscode/vs/platform/markers/common/markers';
|
|
6
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
7
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { NotebookOverviewRulerLane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
9
|
+
import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
10
|
+
import { throttle } from 'vscode/vscode/vs/base/common/decorators';
|
|
11
|
+
import 'vscode/vscode/vs/platform/theme/common/colorUtils';
|
|
12
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
|
|
13
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
14
|
+
import { editorErrorForeground, editorWarningForeground } from 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
|
|
15
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
|
|
16
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
|
|
17
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
|
|
18
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
19
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
|
|
20
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
21
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
22
|
+
import { isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
23
|
+
|
|
24
|
+
let MarkerListProvider = class MarkerListProvider {
|
|
25
|
+
static { this.ID = 'workbench.contrib.markerListProvider'; }
|
|
26
|
+
constructor(_markerService, markerNavigation, _configService) {
|
|
27
|
+
this._markerService = _markerService;
|
|
28
|
+
this._configService = _configService;
|
|
29
|
+
this._dispoables = markerNavigation.registerProvider(this);
|
|
30
|
+
}
|
|
31
|
+
dispose() {
|
|
32
|
+
this._dispoables.dispose();
|
|
33
|
+
}
|
|
34
|
+
getMarkerList(resource) {
|
|
35
|
+
if (!resource) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const data = CellUri.parse(resource);
|
|
39
|
+
if (!data) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return ( new MarkerList(uri => {
|
|
43
|
+
const otherData = CellUri.parse(uri);
|
|
44
|
+
return otherData?.notebook.toString() === ( data.notebook.toString());
|
|
45
|
+
}, this._markerService, this._configService));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
MarkerListProvider = ( __decorate([
|
|
49
|
+
( __param(0, IMarkerService)),
|
|
50
|
+
( __param(1, IMarkerNavigationService)),
|
|
51
|
+
( __param(2, IConfigurationService))
|
|
52
|
+
], MarkerListProvider));
|
|
53
|
+
let NotebookMarkerDecorationContribution = class NotebookMarkerDecorationContribution extends Disposable {
|
|
54
|
+
static { this.id = 'workbench.notebook.markerDecoration'; }
|
|
55
|
+
constructor(_notebookEditor, _markerService) {
|
|
56
|
+
super();
|
|
57
|
+
this._notebookEditor = _notebookEditor;
|
|
58
|
+
this._markerService = _markerService;
|
|
59
|
+
this._markersOverviewRulerDecorations = [];
|
|
60
|
+
this._update();
|
|
61
|
+
this._register(this._notebookEditor.onDidChangeModel(() => this._update()));
|
|
62
|
+
this._register(this._markerService.onMarkerChanged(e => {
|
|
63
|
+
if (( e.some(uri => ( this._notebookEditor.getCellsInRange().some(cell => isEqual(cell.uri, uri)))))) {
|
|
64
|
+
this._update();
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
_update() {
|
|
69
|
+
if (!this._notebookEditor.hasModel()) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const cellDecorations = [];
|
|
73
|
+
this._notebookEditor.getCellsInRange().forEach(cell => {
|
|
74
|
+
const marker = this._markerService.read({ resource: cell.uri, severities: MarkerSeverity.Error | MarkerSeverity.Warning });
|
|
75
|
+
marker.forEach(m => {
|
|
76
|
+
const color = m.severity === MarkerSeverity.Error ? editorErrorForeground : editorWarningForeground;
|
|
77
|
+
const range = { startLineNumber: m.startLineNumber, startColumn: m.startColumn, endLineNumber: m.endLineNumber, endColumn: m.endColumn };
|
|
78
|
+
cellDecorations.push({
|
|
79
|
+
handle: cell.handle,
|
|
80
|
+
options: {
|
|
81
|
+
overviewRuler: {
|
|
82
|
+
color: color,
|
|
83
|
+
modelRanges: [range],
|
|
84
|
+
includeOutput: false,
|
|
85
|
+
position: NotebookOverviewRulerLane.Right
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
this._markersOverviewRulerDecorations = this._notebookEditor.deltaCellDecorations(this._markersOverviewRulerDecorations, cellDecorations);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
NotebookMarkerDecorationContribution.__decorator = ( __decorate([
|
|
95
|
+
throttle(100)
|
|
96
|
+
], NotebookMarkerDecorationContribution.prototype, "_update", null));
|
|
97
|
+
NotebookMarkerDecorationContribution = ( __decorate([
|
|
98
|
+
( __param(1, IMarkerService))
|
|
99
|
+
], NotebookMarkerDecorationContribution));
|
|
100
|
+
registerWorkbenchContribution2(MarkerListProvider.ID, MarkerListProvider, 2 );
|
|
101
|
+
registerNotebookContribution(NotebookMarkerDecorationContribution.id, NotebookMarkerDecorationContribution);
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { timeout } from 'vscode/vscode/vs/base/common/async';
|
|
2
|
+
import { EditorExtensionsRegistry } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
3
|
+
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
4
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
5
|
+
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
|
|
6
|
+
import { registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
7
|
+
import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
8
|
+
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
9
|
+
import { InputFocusedContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
|
|
10
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
11
|
+
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
12
|
+
import { CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext';
|
|
13
|
+
import { NotebookCellAction, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, findTargetCellEditor, NotebookAction } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
14
|
+
import { CellEditState } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
15
|
+
import { NOTEBOOK_EDITOR_CURSOR_BOUNDARY, CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
16
|
+
import { NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_CELL_TYPE, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CURSOR_NAVIGATION_MODE, NOTEBOOK_OUTPUT_FOCUSED, NOTEBOOK_CELL_HAS_OUTPUTS } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
17
|
+
|
|
18
|
+
const NOTEBOOK_FOCUS_TOP = 'notebook.focusTop';
|
|
19
|
+
const NOTEBOOK_FOCUS_BOTTOM = 'notebook.focusBottom';
|
|
20
|
+
const NOTEBOOK_FOCUS_PREVIOUS_EDITOR = 'notebook.focusPreviousEditor';
|
|
21
|
+
const NOTEBOOK_FOCUS_NEXT_EDITOR = 'notebook.focusNextEditor';
|
|
22
|
+
const FOCUS_IN_OUTPUT_COMMAND_ID = 'notebook.cell.focusInOutput';
|
|
23
|
+
const FOCUS_OUT_OUTPUT_COMMAND_ID = 'notebook.cell.focusOutOutput';
|
|
24
|
+
const CENTER_ACTIVE_CELL = 'notebook.centerActiveCell';
|
|
25
|
+
const NOTEBOOK_CURSOR_PAGEUP_COMMAND_ID = 'notebook.cell.cursorPageUp';
|
|
26
|
+
const NOTEBOOK_CURSOR_PAGEUP_SELECT_COMMAND_ID = 'notebook.cell.cursorPageUpSelect';
|
|
27
|
+
const NOTEBOOK_CURSOR_PAGEDOWN_COMMAND_ID = 'notebook.cell.cursorPageDown';
|
|
28
|
+
const NOTEBOOK_CURSOR_PAGEDOWN_SELECT_COMMAND_ID = 'notebook.cell.cursorPageDownSelect';
|
|
29
|
+
registerAction2(class FocusNextCellAction extends NotebookCellAction {
|
|
30
|
+
constructor() {
|
|
31
|
+
super({
|
|
32
|
+
id: NOTEBOOK_FOCUS_NEXT_EDITOR,
|
|
33
|
+
title: ( localizeWithPath(
|
|
34
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
35
|
+
'cursorMoveDown',
|
|
36
|
+
'Focus Next Cell Editor'
|
|
37
|
+
)),
|
|
38
|
+
keybinding: [
|
|
39
|
+
{
|
|
40
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()), ( ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true)), ( ContextKeyExpr.and(( ContextKeyExpr.has(InputFocusedContextKey)), EditorContextKeys.editorTextFocus, ( NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('top')), ( NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none')))), ( EditorContextKeys.isEmbeddedDiffEditor.negate()))),
|
|
41
|
+
primary: 18 ,
|
|
42
|
+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()), ( ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true)), ( ContextKeyExpr.and(( NOTEBOOK_CELL_TYPE.isEqualTo('markup')), ( NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false)), NOTEBOOK_CURSOR_NAVIGATION_MODE)), ( EditorContextKeys.isEmbeddedDiffEditor.negate()))),
|
|
46
|
+
primary: 18 ,
|
|
47
|
+
weight: 200 ,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED)),
|
|
51
|
+
primary: 2048 | 18 ,
|
|
52
|
+
mac: { primary: 256 | 2048 | 18 , },
|
|
53
|
+
weight: 200
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
when: NOTEBOOK_EDITOR_FOCUSED,
|
|
57
|
+
primary: 2048 | 512 | 12 ,
|
|
58
|
+
mac: { primary: 2048 | 512 | 12 , },
|
|
59
|
+
weight: 200
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async runWithContext(accessor, context) {
|
|
65
|
+
const editor = context.notebookEditor;
|
|
66
|
+
const activeCell = context.cell;
|
|
67
|
+
const idx = editor.getCellIndex(activeCell);
|
|
68
|
+
if (typeof idx !== 'number') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (idx >= editor.getLength() - 1) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const focusEditorLine = activeCell.textBuffer.getLineCount();
|
|
75
|
+
const targetCell = (context.cell ?? context.selectedCells?.[0]);
|
|
76
|
+
const foundEditor = targetCell ? findTargetCellEditor(context, targetCell) : undefined;
|
|
77
|
+
if (foundEditor && foundEditor.hasTextFocus() && InlineChatController.get(foundEditor)?.getWidgetPosition()?.lineNumber === focusEditorLine) {
|
|
78
|
+
InlineChatController.get(foundEditor)?.focus();
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const newCell = editor.cellAt(idx + 1);
|
|
82
|
+
const newFocusMode = newCell.cellKind === CellKind.Markup && newCell.getEditState() === CellEditState.Preview ? 'container' : 'editor';
|
|
83
|
+
await editor.focusNotebookCell(newCell, newFocusMode, { focusEditorLine: 1 });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
registerAction2(class FocusPreviousCellAction extends NotebookCellAction {
|
|
88
|
+
constructor() {
|
|
89
|
+
super({
|
|
90
|
+
id: NOTEBOOK_FOCUS_PREVIOUS_EDITOR,
|
|
91
|
+
title: ( localizeWithPath(
|
|
92
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
93
|
+
'cursorMoveUp',
|
|
94
|
+
'Focus Previous Cell Editor'
|
|
95
|
+
)),
|
|
96
|
+
keybinding: [
|
|
97
|
+
{
|
|
98
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()), ( ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true)), ( ContextKeyExpr.and(( ContextKeyExpr.has(InputFocusedContextKey)), EditorContextKeys.editorTextFocus, ( NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('bottom')), ( NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none')))), ( EditorContextKeys.isEmbeddedDiffEditor.negate()))),
|
|
99
|
+
primary: 16 ,
|
|
100
|
+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()), ( ContextKeyExpr.equals('config.notebook.navigation.allowNavigateToSurroundingCells', true)), ( ContextKeyExpr.and(( NOTEBOOK_CELL_TYPE.isEqualTo('markup')), ( NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false)), NOTEBOOK_CURSOR_NAVIGATION_MODE)), ( EditorContextKeys.isEmbeddedDiffEditor.negate()))),
|
|
104
|
+
primary: 16 ,
|
|
105
|
+
weight: 200 ,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
when: NOTEBOOK_EDITOR_FOCUSED,
|
|
109
|
+
primary: 2048 | 512 | 11 ,
|
|
110
|
+
mac: { primary: 2048 | 512 | 11 },
|
|
111
|
+
weight: 200
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async runWithContext(accessor, context) {
|
|
117
|
+
const editor = context.notebookEditor;
|
|
118
|
+
const activeCell = context.cell;
|
|
119
|
+
const idx = editor.getCellIndex(activeCell);
|
|
120
|
+
if (typeof idx !== 'number') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (idx < 1 || editor.getLength() === 0) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const newCell = editor.cellAt(idx - 1);
|
|
127
|
+
const newFocusMode = newCell.cellKind === CellKind.Markup && newCell.getEditState() === CellEditState.Preview ? 'container' : 'editor';
|
|
128
|
+
const focusEditorLine = newCell.textBuffer.getLineCount();
|
|
129
|
+
await editor.focusNotebookCell(newCell, newFocusMode, { focusEditorLine: focusEditorLine });
|
|
130
|
+
const foundEditor = findTargetCellEditor(context, newCell);
|
|
131
|
+
if (foundEditor && InlineChatController.get(foundEditor)?.getWidgetPosition()?.lineNumber === focusEditorLine) {
|
|
132
|
+
InlineChatController.get(foundEditor)?.focus();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
registerAction2(class extends NotebookAction {
|
|
137
|
+
constructor() {
|
|
138
|
+
super({
|
|
139
|
+
id: NOTEBOOK_FOCUS_TOP,
|
|
140
|
+
title: ( localizeWithPath(
|
|
141
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
142
|
+
'focusFirstCell',
|
|
143
|
+
'Focus First Cell'
|
|
144
|
+
)),
|
|
145
|
+
keybinding: [
|
|
146
|
+
{
|
|
147
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
|
|
148
|
+
primary: 2048 | 14 ,
|
|
149
|
+
weight: 200
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
when: ( ContextKeyExpr.and(
|
|
153
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
154
|
+
ContextKeyExpr.not(InputFocusedContextKey),
|
|
155
|
+
( CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION.isEqualTo(''))
|
|
156
|
+
)),
|
|
157
|
+
mac: { primary: 2048 | 16 },
|
|
158
|
+
weight: 200
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
async runWithContext(accessor, context) {
|
|
164
|
+
const editor = context.notebookEditor;
|
|
165
|
+
if (editor.getLength() === 0) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const firstCell = editor.cellAt(0);
|
|
169
|
+
await editor.focusNotebookCell(firstCell, 'container');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
registerAction2(class extends NotebookAction {
|
|
173
|
+
constructor() {
|
|
174
|
+
super({
|
|
175
|
+
id: NOTEBOOK_FOCUS_BOTTOM,
|
|
176
|
+
title: ( localizeWithPath(
|
|
177
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
178
|
+
'focusLastCell',
|
|
179
|
+
'Focus Last Cell'
|
|
180
|
+
)),
|
|
181
|
+
keybinding: [
|
|
182
|
+
{
|
|
183
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey))),
|
|
184
|
+
primary: 2048 | 13 ,
|
|
185
|
+
mac: undefined,
|
|
186
|
+
weight: 200
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
when: ( ContextKeyExpr.and(
|
|
190
|
+
NOTEBOOK_EDITOR_FOCUSED,
|
|
191
|
+
ContextKeyExpr.not(InputFocusedContextKey),
|
|
192
|
+
( CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION.isEqualTo(''))
|
|
193
|
+
)),
|
|
194
|
+
mac: { primary: 2048 | 18 },
|
|
195
|
+
weight: 200
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async runWithContext(accessor, context) {
|
|
201
|
+
const editor = context.notebookEditor;
|
|
202
|
+
if (!editor.hasModel() || editor.getLength() === 0) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const lastIdx = editor.getLength() - 1;
|
|
206
|
+
const lastVisibleIdx = editor.getPreviousVisibleCellIndex(lastIdx);
|
|
207
|
+
if (lastVisibleIdx) {
|
|
208
|
+
const cell = editor.cellAt(lastVisibleIdx);
|
|
209
|
+
await editor.focusNotebookCell(cell, 'container');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
registerAction2(class extends NotebookCellAction {
|
|
214
|
+
constructor() {
|
|
215
|
+
super({
|
|
216
|
+
id: FOCUS_IN_OUTPUT_COMMAND_ID,
|
|
217
|
+
title: ( localizeWithPath(
|
|
218
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
219
|
+
'focusOutput',
|
|
220
|
+
'Focus In Active Cell Output'
|
|
221
|
+
)),
|
|
222
|
+
keybinding: {
|
|
223
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_CELL_HAS_OUTPUTS)),
|
|
224
|
+
primary: 2048 | 18 ,
|
|
225
|
+
mac: { primary: 256 | 2048 | 18 , },
|
|
226
|
+
weight: 200
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async runWithContext(accessor, context) {
|
|
231
|
+
const editor = context.notebookEditor;
|
|
232
|
+
const activeCell = context.cell;
|
|
233
|
+
return timeout(0).then(() => editor.focusNotebookCell(activeCell, 'output'));
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
registerAction2(class extends NotebookCellAction {
|
|
237
|
+
constructor() {
|
|
238
|
+
super({
|
|
239
|
+
id: FOCUS_OUT_OUTPUT_COMMAND_ID,
|
|
240
|
+
title: ( localizeWithPath(
|
|
241
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
242
|
+
'focusOutputOut',
|
|
243
|
+
'Focus Out Active Cell Output'
|
|
244
|
+
)),
|
|
245
|
+
keybinding: {
|
|
246
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED)),
|
|
247
|
+
primary: 2048 | 16 ,
|
|
248
|
+
mac: { primary: 256 | 2048 | 16 , },
|
|
249
|
+
weight: 200
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
async runWithContext(accessor, context) {
|
|
254
|
+
const editor = context.notebookEditor;
|
|
255
|
+
const activeCell = context.cell;
|
|
256
|
+
await editor.focusNotebookCell(activeCell, 'editor');
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
registerAction2(class CenterActiveCellAction extends NotebookCellAction {
|
|
260
|
+
constructor() {
|
|
261
|
+
super({
|
|
262
|
+
id: CENTER_ACTIVE_CELL,
|
|
263
|
+
title: ( localizeWithPath(
|
|
264
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
265
|
+
'notebookActions.centerActiveCell',
|
|
266
|
+
"Center Active Cell"
|
|
267
|
+
)),
|
|
268
|
+
keybinding: {
|
|
269
|
+
when: NOTEBOOK_EDITOR_FOCUSED,
|
|
270
|
+
primary: 2048 | 42 ,
|
|
271
|
+
mac: {
|
|
272
|
+
primary: 256 | 42 ,
|
|
273
|
+
},
|
|
274
|
+
weight: 200
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
async runWithContext(accessor, context) {
|
|
279
|
+
return context.notebookEditor.revealInCenter(context.cell);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
registerAction2(class extends NotebookCellAction {
|
|
283
|
+
constructor() {
|
|
284
|
+
super({
|
|
285
|
+
id: NOTEBOOK_CURSOR_PAGEUP_COMMAND_ID,
|
|
286
|
+
title: ( localizeWithPath(
|
|
287
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
288
|
+
'cursorPageUp',
|
|
289
|
+
"Cell Cursor Page Up"
|
|
290
|
+
)),
|
|
291
|
+
keybinding: [
|
|
292
|
+
{
|
|
293
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( ContextKeyExpr.has(InputFocusedContextKey)), EditorContextKeys.editorTextFocus)),
|
|
294
|
+
primary: 11 ,
|
|
295
|
+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
|
|
296
|
+
}
|
|
297
|
+
]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
async runWithContext(accessor, context) {
|
|
301
|
+
EditorExtensionsRegistry.getEditorCommand('cursorPageUp').runCommand(accessor, { pageSize: getPageSize(context) });
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
registerAction2(class extends NotebookCellAction {
|
|
305
|
+
constructor() {
|
|
306
|
+
super({
|
|
307
|
+
id: NOTEBOOK_CURSOR_PAGEUP_SELECT_COMMAND_ID,
|
|
308
|
+
title: ( localizeWithPath(
|
|
309
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
310
|
+
'cursorPageUpSelect',
|
|
311
|
+
"Cell Cursor Page Up Select"
|
|
312
|
+
)),
|
|
313
|
+
keybinding: [
|
|
314
|
+
{
|
|
315
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( ContextKeyExpr.has(InputFocusedContextKey)), EditorContextKeys.editorTextFocus, ( NOTEBOOK_OUTPUT_FOCUSED.negate()))),
|
|
316
|
+
primary: 1024 | 11 ,
|
|
317
|
+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
async runWithContext(accessor, context) {
|
|
323
|
+
EditorExtensionsRegistry.getEditorCommand('cursorPageUpSelect').runCommand(accessor, { pageSize: getPageSize(context) });
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
registerAction2(class extends NotebookCellAction {
|
|
327
|
+
constructor() {
|
|
328
|
+
super({
|
|
329
|
+
id: NOTEBOOK_CURSOR_PAGEDOWN_COMMAND_ID,
|
|
330
|
+
title: ( localizeWithPath(
|
|
331
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
332
|
+
'cursorPageDown',
|
|
333
|
+
"Cell Cursor Page Down"
|
|
334
|
+
)),
|
|
335
|
+
keybinding: [
|
|
336
|
+
{
|
|
337
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( ContextKeyExpr.has(InputFocusedContextKey)), EditorContextKeys.editorTextFocus)),
|
|
338
|
+
primary: 12 ,
|
|
339
|
+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
|
|
340
|
+
}
|
|
341
|
+
]
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
async runWithContext(accessor, context) {
|
|
345
|
+
EditorExtensionsRegistry.getEditorCommand('cursorPageDown').runCommand(accessor, { pageSize: getPageSize(context) });
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
registerAction2(class extends NotebookCellAction {
|
|
349
|
+
constructor() {
|
|
350
|
+
super({
|
|
351
|
+
id: NOTEBOOK_CURSOR_PAGEDOWN_SELECT_COMMAND_ID,
|
|
352
|
+
title: ( localizeWithPath(
|
|
353
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
354
|
+
'cursorPageDownSelect',
|
|
355
|
+
"Cell Cursor Page Down Select"
|
|
356
|
+
)),
|
|
357
|
+
keybinding: [
|
|
358
|
+
{
|
|
359
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( ContextKeyExpr.has(InputFocusedContextKey)), EditorContextKeys.editorTextFocus, ( NOTEBOOK_OUTPUT_FOCUSED.negate()))),
|
|
360
|
+
primary: 1024 | 12 ,
|
|
361
|
+
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
async runWithContext(accessor, context) {
|
|
367
|
+
EditorExtensionsRegistry.getEditorCommand('cursorPageDownSelect').runCommand(accessor, { pageSize: getPageSize(context) });
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
function getPageSize(context) {
|
|
371
|
+
const editor = context.notebookEditor;
|
|
372
|
+
const layoutInfo = editor.getViewModel().layoutInfo;
|
|
373
|
+
const lineHeight = layoutInfo?.fontInfo.lineHeight || 17;
|
|
374
|
+
return Math.max(1, Math.floor((layoutInfo?.height || 0) / lineHeight) - 2);
|
|
375
|
+
}
|
|
376
|
+
( Registry.as(Extensions.Configuration)).registerConfiguration({
|
|
377
|
+
id: 'notebook',
|
|
378
|
+
order: 100,
|
|
379
|
+
type: 'object',
|
|
380
|
+
'properties': {
|
|
381
|
+
'notebook.navigation.allowNavigateToSurroundingCells': {
|
|
382
|
+
type: 'boolean',
|
|
383
|
+
default: true,
|
|
384
|
+
markdownDescription: ( localizeWithPath(
|
|
385
|
+
'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow',
|
|
386
|
+
'notebook.navigation.allowNavigateToSurroundingCells',
|
|
387
|
+
"When enabled cursor can navigate to the next/previous cell when the current cursor in the cell editor is at the first/last line."
|
|
388
|
+
))
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
export { CENTER_ACTIVE_CELL };
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
5
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
6
|
+
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
7
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
8
|
+
import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
|
|
9
|
+
import { VIEWLET_ID } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
|
|
10
|
+
import { NOTEBOOK_VARIABLE_VIEW_ENABLED } from './notebookVariableContextKeys.js';
|
|
11
|
+
import { NotebookVariablesView } from './notebookVariablesView.js';
|
|
12
|
+
import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
13
|
+
import { variablesViewIcon } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
|
|
14
|
+
import { NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
15
|
+
import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
|
|
16
|
+
import { INotebookKernelService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookKernelService';
|
|
17
|
+
import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService';
|
|
18
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
19
|
+
|
|
20
|
+
let NotebookVariables = class NotebookVariables extends Disposable {
|
|
21
|
+
constructor(contextKeyService, configurationService, editorService, notebookExecutionStateService, notebookKernelService, notebookDocumentService) {
|
|
22
|
+
super();
|
|
23
|
+
this.configurationService = configurationService;
|
|
24
|
+
this.editorService = editorService;
|
|
25
|
+
this.notebookExecutionStateService = notebookExecutionStateService;
|
|
26
|
+
this.notebookKernelService = notebookKernelService;
|
|
27
|
+
this.notebookDocumentService = notebookDocumentService;
|
|
28
|
+
this.listeners = [];
|
|
29
|
+
this.initialized = false;
|
|
30
|
+
this.viewEnabled = NOTEBOOK_VARIABLE_VIEW_ENABLED.bindTo(contextKeyService);
|
|
31
|
+
this.listeners.push(this.editorService.onDidActiveEditorChange(() => this.handleInitEvent()));
|
|
32
|
+
this.listeners.push(this.notebookExecutionStateService.onDidChangeExecution((e) => this.handleInitEvent(e.notebook)));
|
|
33
|
+
this.configListener = configurationService.onDidChangeConfiguration((e) => this.handleConfigChange(e));
|
|
34
|
+
}
|
|
35
|
+
handleConfigChange(e) {
|
|
36
|
+
if (e.affectsConfiguration(NotebookSetting.notebookVariablesView)) {
|
|
37
|
+
if (!this.configurationService.getValue(NotebookSetting.notebookVariablesView)) {
|
|
38
|
+
this.viewEnabled.set(false);
|
|
39
|
+
}
|
|
40
|
+
else if (this.initialized) {
|
|
41
|
+
this.viewEnabled.set(true);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.handleInitEvent();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
handleInitEvent(notebook) {
|
|
49
|
+
if (this.configurationService.getValue(NotebookSetting.notebookVariablesView)
|
|
50
|
+
&& (!!notebook || this.editorService.activeEditorPane?.getId() === 'workbench.editor.notebook')) {
|
|
51
|
+
if (this.hasVariableProvider(notebook) && !this.initialized && this.initializeView()) {
|
|
52
|
+
this.viewEnabled.set(true);
|
|
53
|
+
this.initialized = true;
|
|
54
|
+
this.listeners.forEach(listener => listener.dispose());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
hasVariableProvider(notebookUri) {
|
|
59
|
+
const notebook = notebookUri ?
|
|
60
|
+
this.notebookDocumentService.getNotebookTextModel(notebookUri) :
|
|
61
|
+
getNotebookEditorFromEditorPane(this.editorService.activeEditorPane)?.getViewModel()?.notebookDocument;
|
|
62
|
+
return notebook && this.notebookKernelService.getMatchingKernel(notebook).selected?.hasVariableProvider;
|
|
63
|
+
}
|
|
64
|
+
initializeView() {
|
|
65
|
+
const debugViewContainer = ( Registry.as('workbench.registry.view.containers')).get(VIEWLET_ID);
|
|
66
|
+
if (debugViewContainer) {
|
|
67
|
+
const viewsRegistry = ( Registry.as(Extensions.ViewsRegistry));
|
|
68
|
+
const viewDescriptor = {
|
|
69
|
+
id: 'NOTEBOOK_VARIABLES', name: ( localize2WithPath(
|
|
70
|
+
'vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables',
|
|
71
|
+
'notebookVariables',
|
|
72
|
+
"Notebook Variables"
|
|
73
|
+
)),
|
|
74
|
+
containerIcon: variablesViewIcon, ctorDescriptor: ( new SyncDescriptor(NotebookVariablesView)),
|
|
75
|
+
order: 50, weight: 5, canToggleVisibility: true, canMoveView: true, collapsed: true, when: NOTEBOOK_VARIABLE_VIEW_ENABLED,
|
|
76
|
+
};
|
|
77
|
+
viewsRegistry.registerViews([viewDescriptor], debugViewContainer);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
dispose() {
|
|
83
|
+
super.dispose();
|
|
84
|
+
this.listeners.forEach(listener => listener.dispose());
|
|
85
|
+
this.configListener.dispose();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
NotebookVariables = ( __decorate([
|
|
89
|
+
( __param(0, IContextKeyService)),
|
|
90
|
+
( __param(1, IConfigurationService)),
|
|
91
|
+
( __param(2, IEditorService)),
|
|
92
|
+
( __param(3, INotebookExecutionStateService)),
|
|
93
|
+
( __param(4, INotebookKernelService)),
|
|
94
|
+
( __param(5, INotebookService))
|
|
95
|
+
], NotebookVariables));
|
|
96
|
+
|
|
97
|
+
export { NotebookVariables };
|