From a7d830e26abca70b9b64d8cc8a06eea28c935a29 Mon Sep 17 00:00:00 2001 From: Christoffer Artmann Date: Mon, 15 Dec 2025 16:00:50 +0100 Subject: [PATCH] fix: Keep the dataframe in view when you reduce its size. --- .../extension-side/dataframe/dataframeController.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/webviews/extension-side/dataframe/dataframeController.ts b/src/webviews/extension-side/dataframe/dataframeController.ts index b6ba2c640..69c7170f4 100644 --- a/src/webviews/extension-side/dataframe/dataframeController.ts +++ b/src/webviews/extension-side/dataframe/dataframeController.ts @@ -4,6 +4,8 @@ import { env, l10n, NotebookEdit, + NotebookEditorRevealType, + NotebookRange, type NotebookCellOutput, type NotebookEditor, type NotebookRendererMessaging, @@ -293,6 +295,11 @@ export class DataframeController implements IExtensionSyncActivationService { ranges: [{ start: cellIndex, end: cellIndex + 1 }], document: editor.notebook.uri }); + + // Reveal the cell to keep it visible after output size changes + const notebookRange = new NotebookRange(cellIndex, cellIndex + 1); + + editor.revealRange(notebookRange, NotebookEditorRevealType.InCenterIfOutsideViewport); } private async handleSelectPageSize(editor: NotebookEditor, message: SelectPageSizeCommand) { @@ -342,6 +349,11 @@ export class DataframeController implements IExtensionSyncActivationService { ranges: [{ start: cellIndex, end: cellIndex + 1 }], document: editor.notebook.uri }); + + // Reveal the cell to keep it visible after output size changes + const notebookRange = new NotebookRange(cellIndex, cellIndex + 1); + + editor.revealRange(notebookRange, NotebookEditorRevealType.InCenterIfOutsideViewport); } private async onDidReceiveMessage(