Skip to content

Commit eebdf81

Browse files
authored
Organize notebook related services (microsoft#157966)
1 parent 17c169a commit eebdf81

22 files changed

+130
-126
lines changed

src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { MainThreadNotebookEditors } from 'vs/workbench/api/browser/mainThreadNo
1313
import { extHostCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
1414
import { editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
1515
import { getNotebookEditorFromEditorPane, IActiveNotebookEditor, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
16-
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
16+
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
1717
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
1818
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
1919
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';

src/vs/workbench/api/browser/mainThreadNotebookEditors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { DisposableStore, dispose } from 'vs/base/common/lifecycle';
77
import { getNotebookEditorFromEditorPane, INotebookEditor, INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
8-
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
8+
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
99
import { ExtHostContext, ExtHostNotebookEditorsShape, ICellEditOperationDto, INotebookDocumentShowOptions, INotebookEditorViewColumnInfo, MainThreadNotebookEditorsShape, NotebookEditorRevealType } from '../common/extHost.protocol';
1010
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
1111
import { ILogService } from 'vs/platform/log/common/log';

src/vs/workbench/api/browser/mainThreadNotebookKernels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
1313
import { NotebookDto } from 'vs/workbench/api/browser/mainThreadNotebookDto';
1414
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
1515
import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
16-
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
16+
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
1717
import { INotebookCellExecution, INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
1818
import { INotebookKernel, INotebookKernelChangeEvent, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
1919
import { SerializableObjectWithBuffers } from 'vs/workbench/services/extensions/common/proxyIdentifier';

src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/
2424
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput';
2525
import { ICellViewModel, INotebookEditorOptions, INotebookEditorViewState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
2626
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
27-
import { IBorrowValue, INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
27+
import { IBorrowValue, INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
2828
import { cellEditorBackground, NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
2929
import { GroupsOrder, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
3030
import { ExecutionStateCellStatusBarContrib, TimerCellStatusBarContrib } from 'vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController';

src/vs/workbench/contrib/notebook/browser/controller/coreActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_IS_ACTIVE_E
1414
import { ICellRange, isICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
1515
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1616
import { IEditorCommandsContext } from 'vs/workbench/common/editor';
17-
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
17+
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
1818
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1919
import { WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from 'vs/base/common/actions';
2020
import { TypeConstraint } from 'vs/base/common/types';

src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { EditorInput } from 'vs/workbench/common/editor/editorInput';
2828
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
2929
import { isCompositeNotebookEditorInput, NotebookEditorInput, NotebookEditorInputOptions } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
3030
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
31-
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl';
31+
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/services/notebookServiceImpl';
3232
import { CellKind, CellUri, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookWorkingCopyTypeIdentifier, NotebookSetting, ICellOutput, ICell } from 'vs/workbench/contrib/notebook/common/notebookCommon';
3333
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
3434
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
@@ -38,16 +38,16 @@ import { NotebookTextDiffEditor } from 'vs/workbench/contrib/notebook/browser/di
3838
import { INotebookEditorWorkerService } from 'vs/workbench/contrib/notebook/common/services/notebookWorkerService';
3939
import { NotebookEditorWorkerServiceImpl } from 'vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl';
4040
import { INotebookCellStatusBarService } from 'vs/workbench/contrib/notebook/common/notebookCellStatusBarService';
41-
import { NotebookCellStatusBarService } from 'vs/workbench/contrib/notebook/browser/notebookCellStatusBarServiceImpl';
42-
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
43-
import { NotebookEditorWidgetService } from 'vs/workbench/contrib/notebook/browser/notebookEditorServiceImpl';
41+
import { NotebookCellStatusBarService } from 'vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl';
42+
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
43+
import { NotebookEditorWidgetService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl';
4444
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
4545
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
4646
import { Event } from 'vs/base/common/event';
4747
import { getFormattedMetadataJSON, getStreamOutputData } from 'vs/workbench/contrib/notebook/browser/diff/diffElementViewModel';
4848
import { NotebookModelResolverServiceImpl } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl';
4949
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
50-
import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl';
50+
import { NotebookKernelService } from 'vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl';
5151
import { IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy';
5252
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
5353
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@@ -56,7 +56,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
5656
import { ILabelService } from 'vs/platform/label/common/label';
5757
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
5858
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
59-
import { NotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/browser/notebookRendererMessagingServiceImpl';
59+
import { NotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl';
6060
import { INotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/common/notebookRendererMessagingService';
6161

6262
// Editor Controller
@@ -94,8 +94,8 @@ import 'vs/workbench/contrib/notebook/browser/diff/notebookDiffActions';
9494

9595
// Services
9696
import { editorOptionsRegistry } from 'vs/editor/common/config/editorOptions';
97-
import { NotebookExecutionStateService } from 'vs/workbench/contrib/notebook/browser/notebookExecutionStateServiceImpl';
98-
import { NotebookExecutionService } from 'vs/workbench/contrib/notebook/browser/notebookExecutionServiceImpl';
97+
import { NotebookExecutionStateService } from 'vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl';
98+
import { NotebookExecutionService } from 'vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl';
9999
import { INotebookExecutionService } from 'vs/workbench/contrib/notebook/common/notebookExecutionService';
100100
import { INotebookKeymapService } from 'vs/workbench/contrib/notebook/common/notebookKeymapService';
101101
import { NotebookKeymapService } from 'vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl';

src/vs/workbench/contrib/notebook/browser/notebookEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { DEFAULT_EDITOR_ASSOCIATION, EditorInputCapabilities, EditorPaneSelectio
2727
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
2828
import { SELECT_KERNEL_ID } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
2929
import { INotebookEditorOptions, INotebookEditorViewState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
30-
import { IBorrowValue, INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
30+
import { IBorrowValue, INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
3131
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
3232
import { NotebooKernelActionViewItem } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookKernelActionViewItem';
3333
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 2 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Color, RGBA } from 'vs/base/common/color';
2121
import { onUnexpectedError } from 'vs/base/common/errors';
2222
import { Emitter, Event } from 'vs/base/common/event';
2323
import { combinedDisposable, Disposable, DisposableStore, dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
24-
import { deepClone } from 'vs/base/common/objects';
2524
import { setTimeout0 } from 'vs/base/common/platform';
2625
import { extname, isEqual } from 'vs/base/common/resources';
2726
import { URI } from 'vs/base/common/uri';
@@ -51,7 +50,7 @@ import { EDITOR_PANE_BACKGROUND, PANEL_BORDER, SIDE_BAR_BACKGROUND } from 'vs/wo
5150
import { debugIconStartForeground } from 'vs/workbench/contrib/debug/browser/debugColors';
5251
import { CellEditState, CellFindMatchWithIndex, CellFocusMode, CellLayoutContext, CellRevealType, IActiveNotebookEditorDelegate, IBaseCellEditorOptions, ICellOutputViewModel, ICellViewModel, ICommonCellInfo, IDisplayOutputLayoutUpdateRequest, IFocusNotebookCellOptions, IInsetRenderOutput, IModelDecorationsChangeAccessor, INotebookDeltaDecoration, INotebookEditor, INotebookEditorContribution, INotebookEditorContributionDescription, INotebookEditorCreationOptions, INotebookEditorDelegate, INotebookEditorMouseEvent, INotebookEditorOptions, INotebookEditorViewState, INotebookViewCellsUpdateEvent, INotebookWebviewMessage, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
5352
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
54-
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
53+
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
5554
import { notebookDebug } from 'vs/workbench/contrib/notebook/browser/notebookLogger';
5655
import { NotebookCellStateChangedEvent, NotebookLayoutChangedEvent, NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookViewEvents';
5756
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys';
@@ -85,102 +84,10 @@ import { IWebview } from 'vs/workbench/contrib/webview/browser/webview';
8584
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
8685
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
8786
import { NotebookPerfMarks } from 'vs/workbench/contrib/notebook/common/notebookPerformance';
87+
import { BaseCellEditorOptions } from 'vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions';
8888

8989
const $ = DOM.$;
9090

91-
export class BaseCellEditorOptions extends Disposable implements IBaseCellEditorOptions {
92-
private static fixedEditorOptions: IEditorOptions = {
93-
scrollBeyondLastLine: false,
94-
scrollbar: {
95-
verticalScrollbarSize: 14,
96-
horizontal: 'auto',
97-
useShadows: true,
98-
verticalHasArrows: false,
99-
horizontalHasArrows: false,
100-
alwaysConsumeMouseWheel: false
101-
},
102-
renderLineHighlightOnlyWhenFocus: true,
103-
overviewRulerLanes: 0,
104-
lineNumbers: 'off',
105-
lineDecorationsWidth: 0,
106-
folding: true,
107-
fixedOverflowWidgets: true,
108-
minimap: { enabled: false },
109-
renderValidationDecorations: 'on',
110-
lineNumbersMinChars: 3
111-
};
112-
113-
private _localDisposableStore = this._register(new DisposableStore());
114-
private readonly _onDidChange = this._register(new Emitter<void>());
115-
readonly onDidChange: Event<void> = this._onDidChange.event;
116-
private _value: IEditorOptions;
117-
118-
get value(): Readonly<IEditorOptions> {
119-
return this._value;
120-
}
121-
122-
constructor(readonly notebookEditor: INotebookEditorDelegate, readonly notebookOptions: NotebookOptions, readonly configurationService: IConfigurationService, readonly language: string) {
123-
super();
124-
this._register(configurationService.onDidChangeConfiguration(e => {
125-
if (e.affectsConfiguration('editor') || e.affectsConfiguration('notebook')) {
126-
this._recomputeOptions();
127-
}
128-
}));
129-
130-
this._register(notebookOptions.onDidChangeOptions(e => {
131-
if (e.cellStatusBarVisibility || e.editorTopPadding || e.editorOptionsCustomizations) {
132-
this._recomputeOptions();
133-
}
134-
}));
135-
136-
this._register(this.notebookEditor.onDidChangeModel(() => {
137-
this._localDisposableStore.clear();
138-
139-
if (this.notebookEditor.hasModel()) {
140-
this._localDisposableStore.add(this.notebookEditor.onDidChangeOptions(() => {
141-
this._recomputeOptions();
142-
}));
143-
144-
this._recomputeOptions();
145-
}
146-
}));
147-
148-
if (this.notebookEditor.hasModel()) {
149-
this._localDisposableStore.add(this.notebookEditor.onDidChangeOptions(() => {
150-
this._recomputeOptions();
151-
}));
152-
}
153-
154-
this._value = this._computeEditorOptions();
155-
}
156-
157-
private _recomputeOptions(): void {
158-
this._value = this._computeEditorOptions();
159-
this._onDidChange.fire();
160-
}
161-
162-
private _computeEditorOptions() {
163-
const editorOptions = deepClone(this.configurationService.getValue<IEditorOptions>('editor', { overrideIdentifier: this.language }));
164-
const layoutConfig = this.notebookOptions.getLayoutConfiguration();
165-
const editorOptionsOverrideRaw = layoutConfig.editorOptionsCustomizations ?? {};
166-
const editorOptionsOverride: { [key: string]: any } = {};
167-
for (const key in editorOptionsOverrideRaw) {
168-
if (key.indexOf('editor.') === 0) {
169-
editorOptionsOverride[key.substring(7)] = editorOptionsOverrideRaw[key];
170-
}
171-
}
172-
const computed = Object.freeze({
173-
...editorOptions,
174-
...BaseCellEditorOptions.fixedEditorOptions,
175-
...editorOptionsOverride,
176-
...{ padding: { top: 12, bottom: 12 } },
177-
readOnly: this.notebookEditor.isReadOnly
178-
});
179-
180-
return computed;
181-
}
182-
}
183-
18491
export function getDefaultNotebookCreationOptions(): INotebookEditorCreationOptions {
18592
// We inlined the id to avoid loading comment contrib in tests
18693
const skipContributions = ['editor.contrib.review'];
@@ -2007,10 +1914,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
20071914
return this._list.getAbsoluteTopOfElement(cell);
20081915
}
20091916

2010-
isScrolledToBottom() {
2011-
return this._listViewInfoAccessor.isScrolledToBottom();
2012-
}
2013-
20141917
scrollToBottom() {
20151918
this._listViewInfoAccessor.scrollToBottom();
20161919
}
@@ -2111,10 +2014,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
21112014
return this._listViewInfoAccessor.getVisibleRangesPlusViewportAboveAndBelow();
21122015
}
21132016

2114-
setScrollTop(scrollTop: number) {
2115-
this._listViewInfoAccessor.setScrollTop(scrollTop);
2116-
}
2117-
21182017
//#endregion
21192018

21202019
//#region Decorations

0 commit comments

Comments
 (0)