Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { deepClone } from 'vs/base/common/objects';
import { IEditorOptions, LineNumbersType } from 'vs/editor/common/config/editorOptions';
import { localize } from 'vs/nls';
Expand All @@ -16,13 +16,13 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { Registry } from 'vs/platform/registry/common/platform';
import { ActiveEditorContext } from 'vs/workbench/common/editor';
import { INotebookCellToolbarActionContext, INotebookCommandContext, NotebookMultiCellAction, NOTEBOOK_ACTIONS_CATEGORY } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { ICellViewModel, INotebookEditorDelegate, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModelStateChangeEvent, ICellViewModel, INotebookEditorDelegate, NOTEBOOK_CELL_LINE_NUMBERS, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart';
import { NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { NotebookOptions } from 'vs/workbench/contrib/notebook/common/notebookOptions';

export class CellEditorOptions extends Disposable {

export class CellEditorOptions extends CellPart {
private static fixedEditorOptions: IEditorOptions = {
scrollBeyondLastLine: false,
scrollbar: {
Expand Down Expand Up @@ -86,6 +86,19 @@ export class CellEditorOptions extends Disposable {
this._value = this._computeEditorOptions();
}

prepareRender(): void {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be optional to implement these, seems that parts often don't need to

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not everyone needs updateLayoutNow either so we can probably use override other than abstract

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might still keep it though to ensure that when we add a new CellPart, we are aware that batching DOM read and writes are necessary.

// nothing to read
}
updateLayoutNow(element: ICellViewModel): void {
// nothing to update
}

updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent) {
if (e.cellLineNumberChanged) {
this.setLineNumbers(element.lineNumbers);
}
}

private _recomputeOptions(): void {
this._value = this._computeEditorOptions();
this._onDidChange.fire();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// import * as DOM from 'vs/base/browser/dom';
import { FastDomNode } from 'vs/base/browser/fastDomNode';
import { ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModelStateChangeEvent, ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
Expand Down Expand Up @@ -42,4 +42,8 @@ export class CellFocusIndicator extends CellPart {
this.bottom.domNode.style.transform = `translateY(${cell.layoutInfo.totalHeight - bottomToolbarDimensions.bottomToolbarGap - layoutInfo.cellBottomMargin}px)`;
}
}

updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void {
// nothing to update
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { ViewContainerLocation } from 'vs/workbench/common/views';
import { IExtensionsViewPaneContainer, VIEWLET_ID as EXTENSION_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
import { INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { ICellOutputViewModel, ICellViewModel, IInsetRenderOutput, INotebookEditorDelegate, IRenderOutput, JUPYTER_EXTENSION_ID, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModelStateChangeEvent, ICellOutputViewModel, ICellViewModel, IInsetRenderOutput, INotebookEditorDelegate, IRenderOutput, JUPYTER_EXTENSION_ID, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { mimetypeIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons';
import { CodeCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon';
import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets';
Expand Down Expand Up @@ -602,6 +602,11 @@ export class CellOutputContainer extends CellPart {
});
}


updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void {
// nothing to update
}

render(editorHeight: number) {
if (this.viewCell.outputsViewModels.length > 0) {
if (this.viewCell.layoutInfo.totalHeight !== 0 && this.viewCell.layoutInfo.editorHeight > editorHeight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Disposable } from 'vs/base/common/lifecycle';
import { ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModelStateChangeEvent, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';

export abstract class CellPart extends Disposable {
constructor() {
Expand All @@ -20,4 +20,6 @@ export abstract class CellPart extends Disposable {
* Update DOM based on layout info change of cell
*/
abstract updateLayoutNow(element: ICellViewModel): void;

abstract updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
import { Disposable } from 'vs/base/common/lifecycle';
import { CellViewModelStateChangeEvent } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { NotebookCellExecutionState, NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';

Expand Down Expand Up @@ -34,18 +33,16 @@ export class CellProgressBar extends Disposable {
}
}

updateForCellState(e: CellViewModelStateChangeEvent, element: CodeCellViewModel): void {
if (e.inputCollapsedChanged) {
if (element.isInputCollapsed) {
this._progressBar.hide();
if (element.internalMetadata.runState === NotebookCellExecutionState.Executing) {
showProgressBar(this._collapsedProgressBar);
}
} else {
this._collapsedProgressBar.hide();
if (element.internalMetadata.runState === NotebookCellExecutionState.Executing) {
showProgressBar(this._progressBar);
}
updateForCellState(element: CodeCellViewModel): void {
if (element.isInputCollapsed) {
this._progressBar.hide();
if (element.internalMetadata.runState === NotebookCellExecutionState.Executing) {
showProgressBar(this._collapsedProgressBar);
}
} else {
this._collapsedProgressBar.hide();
if (element.internalMetadata.runState === NotebookCellExecutionState.Executing) {
showProgressBar(this._progressBar);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { DeleteCellAction } from 'vs/workbench/contrib/notebook/browser/controller/editActions';
import { ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModelStateChangeEvent, ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CodiconActionViewItem } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView';
import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart';

Expand Down Expand Up @@ -77,6 +77,11 @@ export class BetweenCellToolbar extends CellPart {
const bottomToolbarOffset = element.layoutInfo.bottomToolbarOffset;
this._bottomCellToolbarContainer.style.transform = `translateY(${bottomToolbarOffset}px)`;
}


updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void {
// nothing to update
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService, ThemeColor } from 'vs/platform/theme/common/themeService';
import { INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellViewModelStateChangeEvent, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart';
import { CellStatusbarAlignment, INotebookCellStatusBarItem } from 'vs/workbench/contrib/notebook/common/notebookCommon';

Expand Down Expand Up @@ -112,6 +112,11 @@ export class CellEditorStatusBar extends CellPart {
this.rightItems.forEach(item => item.maxWidth = maxItemWidth);
}


updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void {
// nothing to update
}

private getMaxItemWidth() {
return this.width / 2;
}
Expand Down
Loading