microsoft / microsoft/vscode

Make notebook cell output item limit (500) configurable via setting

Open
#325,786 1 comment 0 reactions 1 assignee Claimed by @amunger View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

## Problem

When a notebook cell produces many output items (e.g., repeated `print()` calls, logging, tqdm progress bars, or training loops), VS Code hard-caps the rendered output at **500 items** per cell. Once the limit is reached, a message appears:

> "There are more than 500 outputs, show more (open the raw output data in a text editor)"

This limit is **hard-coded** in the source code (`var y0e=500`) with no user-facing setting to adjust it.

### Impact

This affects many real-world use cases:
- **Machine learning training** — long-running training loops that print epoch/loss metrics each iteration
- **Data processing pipelines** — scripts that log progress for thousands of items
- **Debugging with logging** — cells mixing `print()` and `logging` that produce many output items
- **Progress bars (tqdm)** — each update can create a new output item

### Additional Issues

1. The **"show more" link** that is supposed to open the raw output often **crashes** with:
> "Unable to resolve text model content for resource vscode-notebook-cell-output"
(See #226261)

2. The `notebook.output.textLineLimit` setting only controls **text lines per output item**, not the **number of output items** — users naturally expect it to solve this problem but it doesn't.

3. Related issues: #228857, #226261, #110581

## Proposed Solution

Add a new configurable setting:

```
"notebook.output.maxItems": 500
```

- **Default**: `500` (backward compatible, preserves current behavior)
- **Range**: `1` — `10000` (or similar reasonable bounds)
- **Description**: "Maximum number of output items to render per notebook cell. Increase this value if cell outputs are being truncated."

### Implementation Details

The hard-coded limit is located in:
```
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
```

The variable `y0e=500` (minified) maps to the output limit constant used in:
- `NotebookCellOutputContainer` (output renderer)
- `NotebookCodeCellWarmup` (warmup logic)
- `NotebookCodeCellViewModel` (view model slicing)

The fix would involve:
1. Registering the new setting in `notebook.contribution.ts`
2. Reading the setting value instead of using the hard-coded constant
3. Passing it through to the output renderer and related components

## Alternatives Considered

- **Just increase the limit** (e.g., to 5000): Doesn't solve the problem for power users; too high for others
- **Dynamic limit based on output size**: More complex, harder to predict behavior
- **Configurable setting**: Best balance of flexibility and simplicity ✅

## Environment

- VS Code Version: 1.100.0+
- OS: Windows 10/11
- Reproducible: Yes, any notebook cell that produces >500 output items

## Reproduction

```python
# Any simple loop that produces many outputs
for i in range(1000):
print(f"Iteration {i}")
```

This will show "There are more than 500 outputs" with no way to increase the limit via settings.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.