Skip to content

Commit 71abe5f

Browse files
authored
fix: Keep the data frame in view when you reduce its size. (#251)
1 parent e1ec0a7 commit 71abe5f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/test/datascience/mockQuickPick.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Event, EventEmitter, QuickInputButton, QuickPick, QuickPickItem, QuickP
66
export class MockQuickPick implements QuickPick<QuickPickItem> {
77
public value: string = '';
88
public placeholder: string | undefined;
9+
public prompt: string | undefined;
910
public title: string | undefined = 'foo';
1011
public step: number | undefined;
1112
public totalSteps: number | undefined;

src/test/datascience/notebook/helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ export async function hijackSavePrompt(
14211421
export class MockQuickPick implements QuickPick<QuickPickItem> {
14221422
value: string;
14231423
placeholder: string | undefined;
1424+
prompt: string | undefined;
14241425
get onDidChangeValue(): Event<string> {
14251426
return this._onDidChangeValueEmitter.event;
14261427
}

src/webviews/extension-side/dataframe/dataframeController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
env,
55
l10n,
66
NotebookEdit,
7+
NotebookEditorRevealType,
8+
NotebookRange,
79
type NotebookCellOutput,
810
type NotebookEditor,
911
type NotebookRendererMessaging,
@@ -293,6 +295,11 @@ export class DataframeController implements IExtensionSyncActivationService {
293295
ranges: [{ start: cellIndex, end: cellIndex + 1 }],
294296
document: editor.notebook.uri
295297
});
298+
299+
// Reveal the cell to keep it visible after output size changes
300+
const notebookRange = new NotebookRange(cellIndex, cellIndex + 1);
301+
302+
editor.revealRange(notebookRange, NotebookEditorRevealType.InCenterIfOutsideViewport);
296303
}
297304

298305
private async handleSelectPageSize(editor: NotebookEditor, message: SelectPageSizeCommand) {
@@ -342,6 +349,11 @@ export class DataframeController implements IExtensionSyncActivationService {
342349
ranges: [{ start: cellIndex, end: cellIndex + 1 }],
343350
document: editor.notebook.uri
344351
});
352+
353+
// Reveal the cell to keep it visible after output size changes
354+
const notebookRange = new NotebookRange(cellIndex, cellIndex + 1);
355+
356+
editor.revealRange(notebookRange, NotebookEditorRevealType.InCenterIfOutsideViewport);
345357
}
346358

347359
private async onDidReceiveMessage(

0 commit comments

Comments
 (0)