Skip to content

Add a setting to more clearly enable scrolling on cell outputs #11222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 21, 2020
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
1 change: 1 addition & 0 deletions news/2 Fixes/9801.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added 'Enable Scrolling For Cell Outputs' setting. Works together with the 'Max Output Size' setting.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,13 @@
"python.dataScience.maxOutputSize": {
"type": "number",
"default": 400,
"description": "Maximum size (in pixels) of text output in the Python Interactive window before a scrollbar appears. Set to -1 for infinity.",
"description": "Maximum size (in pixels) of text output in the Python Interactive window and Notebook Editor before a scrollbar appears. First enable scrolling for cell outputs in settings.",
"scope": "resource"
},
"python.dataScience.enableScrollingForCellOutputs": {
"type": "boolean",
"default": true,
"description": "Enables scrolling for large cell outputs.",
"scope": "resource"
},
"python.dataScience.errorBackgroundColor": {
Expand Down
1 change: 1 addition & 0 deletions src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export interface IDataScienceSettings {
showCellInputCode: boolean;
collapseCellInputCodeByDefault: boolean;
maxOutputSize: number;
enableScrollingForCellOutputs: boolean;
enableGather?: boolean;
gatherToScript?: boolean;
gatherRules?: IGatherRule[];
Expand Down
2 changes: 2 additions & 0 deletions src/datascience-ui/history-react/interactiveCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface IInteractiveCellBaseProps {
testMode?: boolean;
autoFocus: boolean;
maxTextSize?: number;
enableScroll?: boolean;
showWatermark: boolean;
monacoTheme: string | undefined;
editorOptions?: monacoEditor.editor.IEditorOptions;
Expand Down Expand Up @@ -154,6 +155,7 @@ export class InteractiveCell extends React.Component<IInteractiveCellProps> {
baseTheme={this.props.baseTheme}
expandImage={this.props.showPlot}
maxTextSize={this.props.maxTextSize}
enableScroll={this.props.enableScroll}
themeMatplotlibPlots={themeMatplotlibPlots}
widgetFailed={this.props.widgetFailed}
/>
Expand Down
13 changes: 9 additions & 4 deletions src/datascience-ui/history-react/interactivePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ ${buildSettingsCss(this.props.settings)}`}</style>
return null;
}

const maxOutputSize = this.props.settings.maxOutputSize;
const maxTextSize = maxOutputSize && maxOutputSize < 10000 && maxOutputSize > 0 ? maxOutputSize : undefined;
const executionCount = this.getInputExecutionCount();
const editPanelClass = this.props.settings.colorizeInputBox ? 'edit-panel-colorized' : 'edit-panel';

Expand All @@ -259,7 +257,8 @@ ${buildSettingsCss(this.props.settings)}`}</style>
<InteractiveCellComponent
role="form"
editorOptions={this.props.editorOptions}
maxTextSize={maxTextSize}
maxTextSize={this.getMaxTextSize(this.props.settings.maxOutputSize)}
enableScroll={this.props.settings.enableScrollingForCellOutputs}
autoFocus={document.hasFocus()}
testMode={this.props.testMode}
cellVM={this.props.editCellVM}
Expand Down Expand Up @@ -330,7 +329,8 @@ ${buildSettingsCss(this.props.settings)}`}</style>
<InteractiveCellComponent
role="listitem"
editorOptions={this.props.editorOptions}
maxTextSize={this.props.settings.maxOutputSize}
maxTextSize={this.getMaxTextSize(this.props.settings.maxOutputSize)}
enableScroll={this.props.settings.enableScrollingForCellOutputs}
autoFocus={false}
testMode={this.props.testMode}
cellVM={cellVM}
Expand Down Expand Up @@ -377,6 +377,11 @@ ${buildSettingsCss(this.props.settings)}`}</style>
private linkClick = (ev: MouseEvent) => {
handleLinkClick(ev, this.props.linkClick);
};

private getMaxTextSize(maxOutputSize: number): number | undefined {
const outputSizeLimit = 10000;
return maxOutputSize && maxOutputSize < outputSizeLimit && maxOutputSize > 0 ? maxOutputSize : undefined;
}
}

// Main export, return a redux connected editor
Expand Down
3 changes: 2 additions & 1 deletion src/datascience-ui/interactive-common/cellOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface ICellOutputProps {
cellVM: ICellViewModel;
baseTheme: string;
maxTextSize?: number;
enableScroll?: boolean;
hideOutput?: boolean;
themeMatplotlibPlots?: boolean;
expandImage(imageHtml: string): void;
Expand Down Expand Up @@ -536,7 +537,7 @@ export class CellOutput extends React.Component<ICellOutputProps> {
const style: React.CSSProperties = {};

// Create a scrollbar style if necessary
if (transformedList.some((transformed) => transformed.output.renderWithScrollbars) && this.props.maxTextSize) {
Copy link

Choose a reason for hiding this comment

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

maxTextSize [](start = 105, length = 11)

We already has this value. Why is this not sufficient? It does the same thing

Copy link
Author

Choose a reason for hiding this comment

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

@jmew and I thought renaming it to "Enable scrolling for cell outputs" and having it be a checkbox would be more clear to users (that's how the setting is named in jupyter lab). And I didn't want to remove the functionality to be able to resize the output so I left it in. I'm open to suggestions.

Copy link

Choose a reason for hiding this comment

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

But if maxOutputSize is set to -1, we will suddenly force everybody to have a max output size of 400. When they really wanted no scroll bars.


In reply to: 409903189 [](ancestors = 409903189)

Copy link
Author

Choose a reason for hiding this comment

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

That never happens, if maxOutputSize is set to -1, weather this new setting is true or false, no scrollbar appears.

Copy link

Choose a reason for hiding this comment

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

Not sure I'm following the logic for that.

If maxOutputSize is set to -1, this.props.maxTextSize is undefined.
If the setting for enable scrolling is true, it will go to line 541, where suddenly the text size will be 400


In reply to: 409912783 [](ancestors = 409912783)

Copy link

Choose a reason for hiding this comment

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

image

Copy link

Choose a reason for hiding this comment

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

and @IanMatthewHuff I dont believe they have a setting to control the max height for truncation

Copy link

Choose a reason for hiding this comment

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

I'm fine with the new setting, but we should fix the problem of it auto truncating when maxTextSize is -1. That would be a bug


In reply to: 409925767 [](ancestors = 409925767)

Copy link

Choose a reason for hiding this comment

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

maxTextSize of -1 should be equivalent to enableScrolling being false.


In reply to: 409930365 [](ancestors = 409930365,409925767)

Copy link

Choose a reason for hiding this comment

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

Cause otherwise you're going to break existing users.


In reply to: 409930466 [](ancestors = 409930466,409930365,409925767)

if (transformedList.some((transformed) => transformed.output.renderWithScrollbars) && this.props.enableScroll) {
Copy link

@DonJayamanne DonJayamanne Apr 17, 2020

Choose a reason for hiding this comment

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

Ideally we should just use react context. This way we don't have to pass down props through all these layers.. I know i've brought this up in the past... We keep modifying 3-4 files for such things.

style.overflowY = 'auto';
style.maxHeight = `${this.props.maxTextSize}px`;
}
Expand Down
2 changes: 2 additions & 0 deletions src/datascience-ui/native-editor/nativeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface INativeCellBaseProps {
codeTheme: string;
testMode?: boolean;
maxTextSize?: number;
enableScroll?: boolean;
monacoTheme: string | undefined;
lastCell: boolean;
firstCell: boolean;
Expand Down Expand Up @@ -702,6 +703,7 @@ export class NativeCell extends React.Component<INativeCellProps> {
baseTheme={this.props.baseTheme}
expandImage={this.props.showPlot}
maxTextSize={this.props.maxTextSize}
enableScroll={this.props.enableScroll}
themeMatplotlibPlots={themeMatplotlibPlots}
widgetFailed={this.props.widgetFailed}
/>
Expand Down
8 changes: 7 additions & 1 deletion src/datascience-ui/native-editor/nativeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,18 @@ ${buildSettingsCss(this.props.settings)}`}</style>
/>
) : null;

const maxOutputSize = this.props.settings.maxOutputSize;
const outputSizeLimit = 10000;
const maxTextSize =
maxOutputSize && maxOutputSize < outputSizeLimit && maxOutputSize > 0 ? maxOutputSize : undefined;

return (
<div key={cellVM.cell.id} id={cellVM.cell.id}>
<ErrorBoundary>
<ConnectedNativeCell
role="listitem"
maxTextSize={this.props.settings.maxOutputSize}
maxTextSize={maxTextSize}
enableScroll={this.props.settings.enableScrollingForCellOutputs}
testMode={this.props.testMode}
cellVM={cellVM}
baseTheme={this.props.baseTheme}
Expand Down
1 change: 1 addition & 0 deletions src/datascience-ui/react-common/settingsReactSide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function getDefaultSettings() {
showCellInputCode: true,
collapseCellInputCodeByDefault: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
markdownRegularExpression: '^(#\\s*%%\\s*\\[markdown\\]|#\\s*\\<markdowncell\\>)',
Expand Down
1 change: 1 addition & 0 deletions src/test/common/configSettings/configSettings.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ suite('Python Settings', async () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
1 change: 1 addition & 0 deletions src/test/datascience/color.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ suite('Theme colors', () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
1 change: 1 addition & 0 deletions src/test/datascience/dataScienceIocContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
codeRegularExpression: '^(#\\s*%%|#\\s*\\<codecell\\>|#\\s*In\\[\\d*?\\]|#\\s*In\\[ \\])',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
1 change: 1 addition & 0 deletions src/test/datascience/execution.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ suite('Jupyter Execution', async () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
1 change: 1 addition & 0 deletions src/test/datascience/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function defaultDataScienceSettings(): IDataScienceSettings {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ suite('Interactive window command listener', async () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
1 change: 1 addition & 0 deletions src/test/datascience/jupyter/serverCache.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ suite('Data Science - ServerCache', () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down
1 change: 1 addition & 0 deletions src/test/datascience/jupyterVariables.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ suite('JupyterVariables', () => {
collapseCellInputCodeByDefault: true,
allowInput: true,
maxOutputSize: 400,
enableScrollingForCellOutputs: true,
errorBackgroundColor: '#FFFFFF',
sendSelectionToInteractiveWindow: false,
variableExplorerExclude: 'module;function;builtin_function_or_method',
Expand Down