mirror of
https://github.com/Microsoft/vscode
synced 2024-10-05 19:02:54 +00:00
interactive window read notebook editor directly.
This commit is contained in:
parent
aad574a153
commit
e160a16de6
|
@ -154,8 +154,7 @@ export class MainThreadNotebookEditors implements MainThreadNotebookEditorsShape
|
|||
if (!notebookEditor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
const viewModel = notebookEditor.viewModel;
|
||||
const cell = viewModel.cellAt(range.start);
|
||||
const cell = notebookEditor.cellAt(range.start);
|
||||
if (!cell) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -401,10 +401,10 @@ export class InteractiveEditor extends EditorPane {
|
|||
*/
|
||||
#registerExecutionScrollListener(widget: NotebookEditorWidget & IActiveNotebookEditor) {
|
||||
this.#widgetDisposableStore.add(widget.textModel.onWillAddRemoveCells(e => {
|
||||
const lastViewCell = widget.viewModel.viewCells[widget.viewModel.viewCells.length - 1];
|
||||
const lastViewCell = widget.cellAt(widget.getLength() - 1);
|
||||
|
||||
// check if the last cell is at the bottom
|
||||
if (this.#cellAtBottom(widget, lastViewCell)) {
|
||||
if (lastViewCell && this.#cellAtBottom(widget, lastViewCell)) {
|
||||
this.#state = ScrollingState.StickyToBottom;
|
||||
} else {
|
||||
this.#state = ScrollingState.Initial;
|
||||
|
@ -412,10 +412,10 @@ export class InteractiveEditor extends EditorPane {
|
|||
}));
|
||||
|
||||
this.#widgetDisposableStore.add(widget.onDidScroll(() => {
|
||||
const lastViewCell = widget.viewModel.viewCells[widget.viewModel.viewCells.length - 1];
|
||||
const lastViewCell = widget.cellAt(widget.getLength() - 1);
|
||||
|
||||
// check if the last cell is at the bottom
|
||||
if (this.#cellAtBottom(widget, lastViewCell)) {
|
||||
if (lastViewCell && this.#cellAtBottom(widget, lastViewCell)) {
|
||||
this.#state = ScrollingState.StickyToBottom;
|
||||
} else {
|
||||
this.#state = ScrollingState.Initial;
|
||||
|
@ -426,8 +426,8 @@ export class InteractiveEditor extends EditorPane {
|
|||
for (let i = 0; i < e.rawEvents.length; i++) {
|
||||
const event = e.rawEvents[i];
|
||||
|
||||
if (event.kind === NotebookCellsChangeType.ModelChange && this.#notebookWidget.value?.viewModel) {
|
||||
const lastViewCell = this.#notebookWidget.value.viewModel.viewCells[this.#notebookWidget.value.viewModel.viewCells.length - 1];
|
||||
if (event.kind === NotebookCellsChangeType.ModelChange && this.#notebookWidget.value?.hasModel()) {
|
||||
const lastViewCell = this.#notebookWidget.value.cellAt(this.#notebookWidget.value.getLength() - 1);
|
||||
if (lastViewCell !== this.#lastCell) {
|
||||
this.#lastCellDisposable.clear();
|
||||
this.#lastCell = lastViewCell;
|
||||
|
|
|
@ -307,7 +307,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
dragHandle.setAttribute('draggable', 'true');
|
||||
|
||||
templateData.disposables.add(DOM.addDisposableListener(dragHandle, DOM.EventType.DRAG_END, () => {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.viewModel?.options.isReadOnly) {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.isReadOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.viewModel?.options.isReadOnly) {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.isReadOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
}
|
||||
|
||||
public startExplicitDrag(cell: ICellViewModel, _dragOffsetY: number) {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.viewModel?.options.isReadOnly) {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.isReadOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
}
|
||||
|
||||
public explicitDrag(cell: ICellViewModel, dragOffsetY: number) {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.viewModel?.options.isReadOnly) {
|
||||
if (!this.notebookEditor.notebookOptions.getLayoutConfiguration().dragAndDropEnabled || !!this.notebookEditor.isReadOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue