From 43450e4f655339036278bc624aa630fdd98933f4 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 17 Jun 2020 14:58:30 -0700 Subject: [PATCH] :lipstick: private _. --- .../notebook/browser/notebookEditor.ts | 110 +++++++++--------- .../notebook/browser/notebookServiceImpl.ts | 50 ++++---- .../browser/viewModel/baseCellViewModel.ts | 4 +- .../browser/viewModel/notebookViewModel.ts | 66 +++++------ .../notebook/common/notebookEditorModel.ts | 26 ++--- 5 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts index a6d2662a3b6..e58a82d679d 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts @@ -29,12 +29,12 @@ const NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'NotebookEditorViewState'; export class NotebookEditor extends BaseEditor { static readonly ID: string = 'workbench.editor.notebook'; - private readonly editorMemento: IEditorMemento; - private readonly groupListener = this._register(new MutableDisposable()); - private readonly widgetDisposableStore: DisposableStore = new DisposableStore(); - private widget: IBorrowValue = { value: undefined }; - private rootElement!: HTMLElement; - private dimension?: DOM.Dimension; + private readonly _editorMemento: IEditorMemento; + private readonly _groupListener = this._register(new MutableDisposable()); + private readonly _widgetDisposableStore: DisposableStore = new DisposableStore(); + private _widget: IBorrowValue = { value: undefined }; + private _rootElement!: HTMLElement; + private _dimension?: DOM.Dimension; // todo@rebornix is there a reason that `super.fireOnDidFocus` isn't used? private readonly _onDidFocusWidget = this._register(new Emitter()); @@ -48,24 +48,24 @@ export class NotebookEditor extends BaseEditor { @IThemeService themeService: IThemeService, @IInstantiationService private readonly instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, - @IEditorService private readonly editorService: IEditorService, - @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService, - @INotificationService private readonly notificationService: INotificationService, - @INotebookEditorWidgetService private readonly notebookWidgetService: INotebookEditorWidgetService, + @IEditorService private readonly _editorService: IEditorService, + @IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService, + @INotificationService private readonly _notificationService: INotificationService, + @INotebookEditorWidgetService private readonly _notebookWidgetService: INotebookEditorWidgetService, ) { super(NotebookEditor.ID, telemetryService, themeService, storageService); - this.editorMemento = this.getEditorMemento(editorGroupService, NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY); + this._editorMemento = this.getEditorMemento(_editorGroupService, NOTEBOOK_EDITOR_VIEW_STATE_PREFERENCE_KEY); } set viewModel(newModel: NotebookViewModel | undefined) { - if (this.widget.value) { - this.widget.value.viewModel = newModel; + if (this._widget.value) { + this._widget.value.viewModel = newModel; this._onDidChangeModel.fire(); } } get viewModel() { - return this.widget.value?.viewModel; + return this._widget.value?.viewModel; } get minimumWidth(): number { return 375; } @@ -82,129 +82,129 @@ export class NotebookEditor extends BaseEditor { } protected createEditor(parent: HTMLElement): void { - this.rootElement = DOM.append(parent, DOM.$('.notebook-editor')); + this._rootElement = DOM.append(parent, DOM.$('.notebook-editor')); // this._widget.createEditor(); - this._register(this.onDidFocus(() => this.widget.value?.updateEditorFocus())); - this._register(this.onDidBlur(() => this.widget.value?.updateEditorFocus())); + this._register(this.onDidFocus(() => this._widget.value?.updateEditorFocus())); + this._register(this.onDidBlur(() => this._widget.value?.updateEditorFocus())); } getDomNode() { - return this.rootElement; + return this._rootElement; } getControl(): NotebookEditorWidget | undefined { - return this.widget.value; + return this._widget.value; } onWillHide() { - this.saveEditorViewState(this.input); - if (this.input && this.widget.value) { + this._saveEditorViewState(this.input); + if (this.input && this._widget.value) { // the widget is not transfered to other editor inputs - this.widget.value.onWillHide(); + this._widget.value.onWillHide(); } super.onWillHide(); } setEditorVisible(visible: boolean, group: IEditorGroup | undefined): void { super.setEditorVisible(visible, group); - this.groupListener.value = group?.onWillCloseEditor(e => this.saveEditorViewState(e.editor)); + this._groupListener.value = group?.onWillCloseEditor(e => this._saveEditorViewState(e.editor)); } focus() { super.focus(); - this.widget.value?.focus(); + this._widget.value?.focus(); } async setInput(input: NotebookEditorInput, options: EditorOptions | undefined, token: CancellationToken): Promise { const group = this.group!; - this.saveEditorViewState(this.input); + this._saveEditorViewState(this.input); await super.setInput(input, options, token); - this.widgetDisposableStore.clear(); + this._widgetDisposableStore.clear(); // there currently is a widget which we still own so // we need to hide it before getting a new widget - if (this.widget.value) { - this.widget.value.onWillHide(); + if (this._widget.value) { + this._widget.value.onWillHide(); } - this.widget = this.instantiationService.invokeFunction(this.notebookWidgetService.retrieveWidget, group, input); + this._widget = this.instantiationService.invokeFunction(this._notebookWidgetService.retrieveWidget, group, input); - if (this.dimension) { - this.widget.value!.layout(this.dimension, this.rootElement); + if (this._dimension) { + this._widget.value!.layout(this._dimension, this._rootElement); } - const model = await input.resolve(this.widget.value!.getId()); + const model = await input.resolve(this._widget.value!.getId()); if (model === null) { - this.notificationService.prompt( + this._notificationService.prompt( Severity.Error, localize('fail.noEditor', "Cannot open resource with notebook editor type '${input.viewType}', please check if you have the right extension installed or enabled."), [{ label: localize('fail.reOpen', "Reopen file with VS Code standard text editor"), run: async () => { - const fileEditorInput = this.editorService.createEditorInput({ resource: input.resource, forceFile: true }); + const fileEditorInput = this._editorService.createEditorInput({ resource: input.resource, forceFile: true }); const textOptions: IEditorOptions | ITextEditorOptions = options ? { ...options, override: false } : { override: false }; - await this.editorService.openEditor(fileEditorInput, textOptions); + await this._editorService.openEditor(fileEditorInput, textOptions); } }] ); return; } - const viewState = this.loadTextEditorViewState(input); + const viewState = this._loadTextEditorViewState(input); - await this.widget.value!.setModel(model.notebook, viewState, options); - this.widgetDisposableStore.add(this.widget.value!.onDidFocus(() => this._onDidFocusWidget.fire())); + await this._widget.value!.setModel(model.notebook, viewState, options); + this._widgetDisposableStore.add(this._widget.value!.onDidFocus(() => this._onDidFocusWidget.fire())); - if (this.editorGroupService instanceof EditorPart) { - this.widgetDisposableStore.add(this.editorGroupService.createEditorDropTarget(this.widget.value!.getDomNode(), { + if (this._editorGroupService instanceof EditorPart) { + this._widgetDisposableStore.add(this._editorGroupService.createEditorDropTarget(this._widget.value!.getDomNode(), { groupContainsPredicate: (group) => this.group?.id === group.group.id })); } } clearInput(): void { - if (this.widget.value) { - this.widget.value.onWillHide(); + if (this._widget.value) { + this._widget.value.onWillHide(); } super.clearInput(); } protected saveState(): void { - this.saveEditorViewState(this.input); + this._saveEditorViewState(this.input); super.saveState(); } - private saveEditorViewState(input: IEditorInput | undefined): void { - if (this.group && this.widget.value && input instanceof NotebookEditorInput) { - const state = this.widget.value.getEditorViewState(); - this.editorMemento.saveEditorState(this.group, input.resource, state); + private _saveEditorViewState(input: IEditorInput | undefined): void { + if (this.group && this._widget.value && input instanceof NotebookEditorInput) { + const state = this._widget.value.getEditorViewState(); + this._editorMemento.saveEditorState(this.group, input.resource, state); } } - private loadTextEditorViewState(input: NotebookEditorInput): INotebookEditorViewState | undefined { + private _loadTextEditorViewState(input: NotebookEditorInput): INotebookEditorViewState | undefined { if (this.group) { - return this.editorMemento.loadEditorState(this.group, input.resource); + return this._editorMemento.loadEditorState(this.group, input.resource); } return; } layout(dimension: DOM.Dimension): void { - this.rootElement.classList.toggle('mid-width', dimension.width < 1000 && dimension.width >= 600); - this.rootElement.classList.toggle('narrow-width', dimension.width < 600); - this.dimension = dimension; + this._rootElement.classList.toggle('mid-width', dimension.width < 1000 && dimension.width >= 600); + this._rootElement.classList.toggle('narrow-width', dimension.width < 600); + this._dimension = dimension; - if (!this.widget.value || !(this._input instanceof NotebookEditorInput)) { + if (!this._widget.value || !(this._input instanceof NotebookEditorInput)) { return; } - if (this._input.resource.toString() !== this.widget.value.viewModel?.uri.toString() && this.widget.value?.viewModel) { + if (this._input.resource.toString() !== this._widget.value.viewModel?.uri.toString() && this._widget.value?.viewModel) { // input and widget mismatch // this happens when // 1. open document A, pin the document @@ -214,7 +214,7 @@ export class NotebookEditor extends BaseEditor { return; } - this.widget.value.layout(this.dimension, this.rootElement); + this._widget.value.layout(this._dimension, this._rootElement); } //#endregion diff --git a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts index 773f81ccac1..9b0346cd050 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts @@ -56,7 +56,7 @@ export class NotebookProviderInfoStore implements IDisposable { id: notebookContribution.viewType, displayName: notebookContribution.displayName, selector: notebookContribution.selector || [], - priority: this.convertPriority(notebookContribution.priority), + priority: this._convertPriority(notebookContribution.priority), providerDisplayName: extension.description.isBuiltin ? nls.localize('builtinProviderDisplayName', "Built-in") : extension.description.displayName || extension.description.identifier.value, providerExtensionLocation: extension.description.extensionLocation })); @@ -64,11 +64,11 @@ export class NotebookProviderInfoStore implements IDisposable { } const mementoObject = this._memento.getMemento(StorageScope.GLOBAL); - mementoObject[NotebookProviderInfoStore.CUSTOM_EDITORS_ENTRY_ID] = Array.from(this.contributedEditors.values()); + mementoObject[NotebookProviderInfoStore.CUSTOM_EDITORS_ENTRY_ID] = Array.from(this._contributedEditors.values()); this._memento.saveMemento(); } - private convertPriority(priority?: string) { + private _convertPriority(priority?: string) { if (!priority) { return NotebookEditorPriority.default; } @@ -84,29 +84,29 @@ export class NotebookProviderInfoStore implements IDisposable { dispose(): void { } - private readonly contributedEditors = new Map(); + private readonly _contributedEditors = new Map(); clear() { - this.contributedEditors.clear(); + this._contributedEditors.clear(); } get(viewType: string): NotebookProviderInfo | undefined { - return this.contributedEditors.get(viewType); + return this._contributedEditors.get(viewType); } add(info: NotebookProviderInfo): void { - if (this.contributedEditors.has(info.id)) { + if (this._contributedEditors.has(info.id)) { return; } - this.contributedEditors.set(info.id, info); + this._contributedEditors.set(info.id, info); } getContributedNotebook(resource: URI): readonly NotebookProviderInfo[] { - return [...Iterable.filter(this.contributedEditors.values(), customEditor => resource.scheme === 'untitled' || customEditor.matches(resource))]; + return [...Iterable.filter(this._contributedEditors.values(), customEditor => resource.scheme === 'untitled' || customEditor.matches(resource))]; } public [Symbol.iterator](): Iterator { - return this.contributedEditors.values(); + return this._contributedEditors.values(); } } @@ -180,15 +180,15 @@ export class NotebookService extends Disposable implements INotebookService, ICu private _displayOrder: { userOrder: string[], defaultOrder: string[] } = Object.create(null); constructor( - @IExtensionService private readonly extensionService: IExtensionService, - @IEditorService private readonly editorService: IEditorService, - @IConfigurationService private readonly configurationService: IConfigurationService, - @IAccessibilityService private readonly accessibilityService: IAccessibilityService, - @IStorageService private readonly storageService: IStorageService + @IExtensionService private readonly _extensionService: IExtensionService, + @IEditorService private readonly _editorService: IEditorService, + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IAccessibilityService private readonly _accessibilityService: IAccessibilityService, + @IStorageService private readonly _storageService: IStorageService ) { super(); - this.notebookProviderInfoStore = new NotebookProviderInfoStore(this.storageService); + this.notebookProviderInfoStore = new NotebookProviderInfoStore(this._storageService); this._register(this.notebookProviderInfoStore); notebookProviderExtensionPoint.setHandler((extensions) => { @@ -213,25 +213,25 @@ export class NotebookService extends Disposable implements INotebookService, ICu // console.log(this.notebookRenderersInfoStore); }); - this.editorService.registerCustomEditorViewTypesHandler('Notebook', this); + this._editorService.registerCustomEditorViewTypesHandler('Notebook', this); const updateOrder = () => { - let userOrder = this.configurationService.getValue('notebook.displayOrder'); + let userOrder = this._configurationService.getValue('notebook.displayOrder'); this._displayOrder = { - defaultOrder: this.accessibilityService.isScreenReaderOptimized() ? ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER : NOTEBOOK_DISPLAY_ORDER, + defaultOrder: this._accessibilityService.isScreenReaderOptimized() ? ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER : NOTEBOOK_DISPLAY_ORDER, userOrder: userOrder }; }; updateOrder(); - this._register(this.configurationService.onDidChangeConfiguration(e => { + this._register(this._configurationService.onDidChangeConfiguration(e => { if (e.affectedKeys.indexOf('notebook.displayOrder') >= 0) { updateOrder(); } })); - this._register(this.accessibilityService.onDidChangeScreenReaderOptimized(() => { + this._register(this._accessibilityService.onDidChangeScreenReaderOptimized(() => { updateOrder(); })); } @@ -246,11 +246,11 @@ export class NotebookService extends Disposable implements INotebookService, ICu async canResolve(viewType: string): Promise { if (!this._notebookProviders.has(viewType)) { - await this.extensionService.whenInstalledExtensionsRegistered(); + await this._extensionService.whenInstalledExtensionsRegistered(); // notebook providers/kernels/renderers might use `*` as activation event. - await this.extensionService.activateByEvent(`*`); + await this._extensionService.activateByEvent(`*`); // this awaits full activation of all matching extensions - await this.extensionService.activateByEvent(`onNotebookEditor:${viewType}`); + await this._extensionService.activateByEvent(`onNotebookEditor:${viewType}`); } return this._notebookProviders.has(viewType); } @@ -688,7 +688,7 @@ export class NotebookService extends Disposable implements INotebookService, ICu } listVisibleNotebookEditors(): INotebookEditor[] { - return this.editorService.visibleEditorPanes + return this._editorService.visibleEditorPanes .filter(pane => (pane as any).isNotebookEditor) .map(pane => pane.getControl() as INotebookEditor) .filter(editor => !!editor) diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts index 7924455303f..f5bb93b389e 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts @@ -155,7 +155,7 @@ export abstract class BaseCellViewModel extends Disposable { this._textModel = this._textEditor.getModel() || undefined; if (this._editorViewStates) { - this.restoreViewState(this._editorViewStates); + this._restoreViewState(this._editorViewStates); } this._resolvedDecorations.forEach((value, key) => { @@ -221,7 +221,7 @@ export abstract class BaseCellViewModel extends Disposable { this._editorViewStates = editorViewStates; } - private restoreViewState(state: editorCommon.ICodeEditorViewState | null): void { + private _restoreViewState(state: editorCommon.ICodeEditorViewState | null): void { if (state) { this._textEditor?.restoreViewState(state); } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts index 6e9b0672769..66598146edf 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts @@ -248,9 +248,9 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD private _notebook: NotebookTextModel, readonly eventDispatcher: NotebookEventDispatcher, private _layoutInfo: NotebookLayoutInfo | null, - @IInstantiationService private readonly instantiationService: IInstantiationService, - @IBulkEditService private readonly bulkEditService: IBulkEditService, - @IUndoRedoService private readonly undoService: IUndoRedoService + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IBulkEditService private readonly _bulkEditService: IBulkEditService, + @IUndoRedoService private readonly _undoService: IUndoRedoService ) { super(); @@ -261,7 +261,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD this._register(this._notebook.onDidChangeCells(e => { const diffs = e.map(splice => { return [splice[0], splice[1], splice[2].map(cell => { - return createCellViewModel(this.instantiationService, this, cell as NotebookCellTextModel); + return createCellViewModel(this._instantiationService, this, cell as NotebookCellTextModel); })] as [number, number, CellViewModel[]]; }); @@ -315,7 +315,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD } } - this.undoService.pushElement(new SpliceCellsEdit(this.uri, undoDiff, { + this._undoService.pushElement(new SpliceCellsEdit(this.uri, undoDiff, { insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), setSelections: this._setSelectionsDelegate.bind(this) @@ -345,7 +345,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD })); this._viewCells = this._notebook!.cells.map(cell => { - return createCellViewModel(this.instantiationService, this, cell); + return createCellViewModel(this._instantiationService, this, cell); }); this._viewCells.forEach(cell => { @@ -584,7 +584,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD private _createCellDelegate(index: number, source: string | string[], language: string, type: CellKind) { const cell = this._notebook.createCellTextModel(source, language, type, [], undefined); - let newCell: CellViewModel = createCellViewModel(this.instantiationService, this, cell); + let newCell: CellViewModel = createCellViewModel(this._instantiationService, this, cell); this._viewCells!.splice(index, 0, newCell); this._handleToViewCellMapping.set(newCell.handle, newCell); this._notebook.insertNewCell(index, [cell]); @@ -618,14 +618,14 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD createCell(index: number, source: string | string[], language: string, type: CellKind, metadata: NotebookCellMetadata | undefined, synchronous: boolean, pushUndoStop: boolean = true) { const cell = this._notebook.createCellTextModel(source, language, type, [], metadata); - let newCell: CellViewModel = createCellViewModel(this.instantiationService, this, cell); + let newCell: CellViewModel = createCellViewModel(this._instantiationService, this, cell); this._viewCells!.splice(index, 0, newCell); this._handleToViewCellMapping.set(newCell.handle, newCell); this._notebook.insertNewCell(index, [cell]); this._localStore.add(newCell); if (pushUndoStop) { - this.undoService.pushElement(new InsertCellEdit(this.uri, index, newCell, { + this._undoService.pushElement(new InsertCellEdit(this.uri, index, newCell, { insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), setSelections: this._setSelectionsDelegate.bind(this) @@ -638,13 +638,13 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD } insertCell(index: number, cell: NotebookCellTextModel, synchronous: boolean): CellViewModel { - let newCell: CellViewModel = createCellViewModel(this.instantiationService, this, cell); + let newCell: CellViewModel = createCellViewModel(this._instantiationService, this, cell); this._viewCells!.splice(index, 0, newCell); this._handleToViewCellMapping.set(newCell.handle, newCell); this._notebook.insertNewCell(index, [newCell.model]); this._localStore.add(newCell); - this.undoService.pushElement(new InsertCellEdit(this.uri, index, newCell, { + this._undoService.pushElement(new InsertCellEdit(this.uri, index, newCell, { insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), setSelections: this._setSelectionsDelegate.bind(this) @@ -681,11 +681,11 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD } if (pushUndoStop) { - this.undoService.pushElement(new DeleteCellEdit(this.uri, index, viewCell, { + this._undoService.pushElement(new DeleteCellEdit(this.uri, index, viewCell, { insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), createCellViewModel: (cell: NotebookCellTextModel) => { - return createCellViewModel(this.instantiationService, this, cell); + return createCellViewModel(this._instantiationService, this, cell); }, setSelections: this._setSelectionsDelegate.bind(this) }, this.selectionHandles, endSelections)); @@ -710,7 +710,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD this._notebook.moveCellToIdx(index, newIdx); if (pushedToUndoStack) { - this.undoService.pushElement(new MoveCellEdit(this.uri, index, newIdx, { + this._undoService.pushElement(new MoveCellEdit(this.uri, index, newIdx, { moveCell: (fromIndex: number, toIndex: number) => { this.moveCellToIdx(fromIndex, toIndex, true, false); }, @@ -726,7 +726,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD return true; } - private pushIfAbsent(positions: IPosition[], p: IPosition) { + private _pushIfAbsent(positions: IPosition[], p: IPosition) { const last = positions.length > 0 ? positions[positions.length - 1] : undefined; if (!last || last.lineNumber !== p.lineNumber || last.column !== p.column) { positions.push(p); @@ -738,7 +738,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD * Move end of line split points to the beginning of the next line; * Avoid duplicate split points */ - private splitPointsToBoundaries(splitPoints: IPosition[], textBuffer: IReadonlyTextBuffer): IPosition[] | null { + private _splitPointsToBoundaries(splitPoints: IPosition[], textBuffer: IReadonlyTextBuffer): IPosition[] | null { const boundaries: IPosition[] = []; const lineCnt = textBuffer.getLineCount(); const getLineLen = (lineNumber: number) => { @@ -753,24 +753,24 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD }); // eat-up any split point at the beginning, i.e. we ignore the split point at the very beginning - this.pushIfAbsent(boundaries, new Position(1, 1)); + this._pushIfAbsent(boundaries, new Position(1, 1)); for (let sp of splitPoints) { if (getLineLen(sp.lineNumber) + 1 === sp.column && sp.lineNumber < lineCnt) { sp = new Position(sp.lineNumber + 1, 1); } - this.pushIfAbsent(boundaries, sp); + this._pushIfAbsent(boundaries, sp); } // eat-up any split point at the beginning, i.e. we ignore the split point at the very end - this.pushIfAbsent(boundaries, new Position(lineCnt, getLineLen(lineCnt) + 1)); + this._pushIfAbsent(boundaries, new Position(lineCnt, getLineLen(lineCnt) + 1)); // if we only have two then they describe the whole range and nothing needs to be split return boundaries.length > 2 ? boundaries : null; } - private computeCellLinesContents(cell: IEditableCellViewModel, splitPoints: IPosition[]): string[] | null { - const rangeBoundaries = this.splitPointsToBoundaries(splitPoints, cell.textBuffer); + private _computeCellLinesContents(cell: IEditableCellViewModel, splitPoints: IPosition[]): string[] | null { + const rangeBoundaries = this._splitPointsToBoundaries(splitPoints, cell.textBuffer); if (!rangeBoundaries) { return null; } @@ -804,7 +804,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD return null; } - let newLinesContents = this.computeCellLinesContents(cell, splitPoints); + let newLinesContents = this._computeCellLinesContents(cell, splitPoints); if (newLinesContents) { const editorSelections = cell.getSelections(); @@ -824,7 +824,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD this.selectionHandles = [cell.handle]; - this.undoService.pushElement(new SplitCellEdit( + this._undoService.pushElement(new SplitCellEdit( this.uri, index, cell, @@ -836,7 +836,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), createCellViewModel: (cell: NotebookCellTextModel) => { - return createCellViewModel(this.instantiationService, this, cell); + return createCellViewModel(this._instantiationService, this, cell); }, createCell: this._createCellDelegate.bind(this), setSelections: this._setSelectionsDelegate.bind(this) @@ -898,7 +898,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD await this.deleteCell(index, true, false); - this.undoService.pushElement(new JoinCellEdit( + this._undoService.pushElement(new JoinCellEdit( this.uri, index, direction, @@ -911,7 +911,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), createCellViewModel: (cell: NotebookCellTextModel) => { - return createCellViewModel(this.instantiationService, this, cell); + return createCellViewModel(this._instantiationService, this, cell); }, setSelections: this._setSelectionsDelegate.bind(this) }) @@ -946,7 +946,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD await this.deleteCell(index + 1, true, false); - this.undoService.pushElement(new JoinCellEdit( + this._undoService.pushElement(new JoinCellEdit( this.uri, index + 1, direction, @@ -959,7 +959,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD insertCell: this._insertCellDelegate.bind(this), deleteCell: this._deleteCellDelegate.bind(this), createCellViewModel: (cell: NotebookCellTextModel) => { - return createCellViewModel(this.instantiationService, this, cell); + return createCellViewModel(this._instantiationService, this, cell); }, setSelections: this._setSelectionsDelegate.bind(this) }) @@ -1092,7 +1092,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD const viewCell = cell as CellViewModel; this._lastNotebookEditResource.push(viewCell.uri); return viewCell.resolveTextModel().then(() => { - this.bulkEditService.apply({ edits: [{ edit: { range: range, text: text }, resource: cell.uri }] }, { quotableLabel: 'Notebook Replace' }); + this._bulkEditService.apply({ edits: [{ edit: { range: range, text: text }, resource: cell.uri }] }, { quotableLabel: 'Notebook Replace' }); }); } @@ -1116,21 +1116,21 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD return Promise.all(matches.map(match => { return match.cell.resolveTextModel(); })).then(async () => { - this.bulkEditService.apply({ edits: textEdits }, { quotableLabel: 'Notebook Replace All' }); + this._bulkEditService.apply({ edits: textEdits }, { quotableLabel: 'Notebook Replace All' }); return; }); } canUndo(): boolean { - return this.undoService.canUndo(this.uri); + return this._undoService.canUndo(this.uri); } undo() { - this.undoService.undo(this.uri); + this._undoService.undo(this.uri); } redo() { - this.undoService.redo(this.uri); + this._undoService.redo(this.uri); } equal(notebook: NotebookTextModel) { diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts index e2cabd7cb76..b6c4289bff7 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts @@ -57,9 +57,9 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN constructor( public readonly resource: URI, public readonly viewType: string, - @INotebookService private readonly notebookService: INotebookService, - @IWorkingCopyService private readonly workingCopyService: IWorkingCopyService, - @IBackupFileService private readonly backupFileService: IBackupFileService + @INotebookService private readonly _notebookService: INotebookService, + @IWorkingCopyService private readonly _workingCopyService: IWorkingCopyService, + @IBackupFileService private readonly _backupFileService: IBackupFileService ) { super(); @@ -77,7 +77,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN revert(options?: IRevertOptions): Promise { return input.revert(options); } }; - this._register(this.workingCopyService.registerWorkingCopy(workingCopyAdapter)); + this._register(this._workingCopyService.registerWorkingCopy(workingCopyAdapter)); } capabilities = 0; @@ -85,7 +85,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN async backup(): Promise> { if (this._notebook.supportBackup) { const tokenSource = new CancellationTokenSource(); - const backupId = await this.notebookService.backup(this.viewType, this.resource, tokenSource.token); + const backupId = await this._notebookService.backup(this.viewType, this.resource, tokenSource.token); return { meta: { @@ -107,7 +107,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN async revert(options?: IRevertOptions | undefined): Promise { if (options?.soft) { - await this.backupFileService.discardBackup(this.resource); + await this._backupFileService.discardBackup(this.resource); return; } @@ -126,7 +126,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN return this; } - const backup = await this.backupFileService.resolve(this._workingCopyResource); + const backup = await this._backupFileService.resolve(this._workingCopyResource); if (this.isResolved()) { return this; // Make sure meanwhile someone else did not succeed in loading @@ -147,7 +147,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN const fullRange = content.getRangeAt(0, content.getLength()); const data = JSON.parse(content.getValueInRange(fullRange, EndOfLinePreference.LF)); - const notebook = await this.notebookService.createNotebookFromBackup(this.viewType!, this.resource, data.metadata, data.languages, data.cells, editorId); + const notebook = await this._notebookService.createNotebookFromBackup(this.viewType!, this.resource, data.metadata, data.languages, data.cells, editorId); this._notebook = notebook!; this._name = basename(this._notebook!.uri); @@ -160,14 +160,14 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN this.setDirty(true); })); - await this.backupFileService.discardBackup(this._workingCopyResource); + await this._backupFileService.discardBackup(this._workingCopyResource); this.setDirty(true); return this; } private async loadFromProvider(forceReloadFromDisk: boolean, editorId: string | undefined, backupId: string | undefined) { - const notebook = await this.notebookService.resolveNotebook(this.viewType!, this.resource, forceReloadFromDisk, editorId, backupId); + const notebook = await this._notebookService.resolveNotebook(this.viewType!, this.resource, forceReloadFromDisk, editorId, backupId); this._notebook = notebook!; this._name = basename(this._notebook!.uri); @@ -181,7 +181,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN })); if (backupId) { - await this.backupFileService.discardBackup(this._workingCopyResource); + await this._backupFileService.discardBackup(this._workingCopyResource); this.setDirty(true); } @@ -209,7 +209,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN async save(): Promise { const tokenSource = new CancellationTokenSource(); - await this.notebookService.save(this.notebook.viewType, this.notebook.uri, tokenSource.token); + await this._notebookService.save(this.notebook.viewType, this.notebook.uri, tokenSource.token); this._dirty = false; this._onDidChangeDirty.fire(); return true; @@ -217,7 +217,7 @@ export class NotebookEditorModel extends EditorModel implements IWorkingCopy, IN async saveAs(targetResource: URI): Promise { const tokenSource = new CancellationTokenSource(); - await this.notebookService.saveAs(this.notebook.viewType, this.notebook.uri, targetResource, tokenSource.token); + await this._notebookService.saveAs(this.notebook.viewType, this.notebook.uri, targetResource, tokenSource.token); this._dirty = false; this._onDidChangeDirty.fire(); return true;