Skip to content

csv_preview: #3 Implement data_table columns pining - #56619

Merged
smitbarmase merged 12 commits into
zed-industries:mainfrom
HalavicH:feat/data-table/implement-column-pinning
May 15, 2026
Merged

csv_preview: #3 Implement data_table columns pining#56619
smitbarmase merged 12 commits into
zed-industries:mainfrom
HalavicH:feat/data-table/implement-column-pinning

Conversation

@HalavicH

@HalavicH HalavicH commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds column pinning (freeze) capability to data tables, allowing the first N columns to remain visible while scrolling horizontally through the rest of the table content.

Common spreadsheet/data table UX pattern. When viewing wide tables with many columns, users need to see identifying information (row labels, IDs) while scrolling right to explore data.

Demo

Idle state:
image
Scrolled horizontally (name column dissapeared, line numbers column stayed pinned):
image

Implementation

  • New pin_cols(n: usize) builder method on Table to specify how many columns to pin
  • Pinned columns render in a fixed section that doesn't scroll horizontally
  • Scrollable columns render separately with independent scroll state
  • Horizontal scroll offset adjustments for proper column resize handle positioning with pinned sections
  • Pinned section stays at viewport left edge while scrollable section scrolls independently
  • Supports 0 < pinned_cols < total_cols (partial pinning)
  • Applied to CSV preview for better UX with wide datasets

Context

Part of CSV preview feature series, following PR #53496 (settings UI).

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist no ui changes besides pinning itself. UI improvements out of scope of this PR

Release Notes:

  • Improved CSV preview with column pinning to keep identifiers visible while scrolling

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 13, 2026
@HalavicH
HalavicH marked this pull request as ready for review May 13, 2026 09:58
@smitbarmase smitbarmase self-assigned this May 13, 2026
@Anthony-Eid

Copy link
Copy Markdown
Contributor

I think for a feature like this it's important to have tests asserting the behavior we want

cc: @smitbarmase

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I found a few nits, but there is one panic here that we should address first.

Comment thread crates/csv_preview/src/renderer/render_table.rs
Comment thread crates/ui/src/components/data_table.rs Outdated
Comment thread crates/csv_preview/src/renderer/render_table.rs
Comment thread crates/ui/src/components/data_table.rs Outdated
HalavicH and others added 8 commits May 14, 2026 11:30
- Fix panic: clamp pinned_cols to valid range before slicing widths
- Remove 4 redundant clones in header rendering (clippy errors)
- Consolidate duplicate "disable if" cell-styling logic with render_cell() helper
- Move pinned_width/total_scrollable_width computation into render_resize_handles_resizable()

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I refactored the code a bit and added a few basic tests. I think this is much cleaner now.

@smitbarmase
smitbarmase enabled auto-merge May 15, 2026 07:58
@smitbarmase
smitbarmase added this pull request to the merge queue May 15, 2026
Merged via the queue into zed-industries:main with commit dca5976 May 15, 2026
49 of 51 checks passed
@HalavicH HalavicH changed the title csv_preview: Implement data_table columns pining csv_preview: #3 Implement data_table columns pining Jul 13, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
## Summary

Adds column pinning (freeze) capability to data tables, allowing the
first N columns to remain visible while scrolling horizontally through
the rest of the table content.

Common spreadsheet/data table UX pattern. When viewing wide tables with
many columns, users need to see identifying information (row labels,
IDs) while scrolling right to explore data.

## Demo
Idle state:
<img width="559" height="179" alt="image"
src="https://github.com/user-attachments/assets/b3f89221-8aa9-4e8a-9a39-6f06cc8a4eea"
/>
Scrolled horizontally (name column dissapeared, line numbers column
stayed pinned):
<img width="522" height="174" alt="image"
src="https://github.com/user-attachments/assets/c6695a00-5e40-49b8-81d7-0b30e26bb7bb"
/>

## Implementation

- New `pin_cols(n: usize)` builder method on `Table` to specify how many
columns to pin
- Pinned columns render in a fixed section that doesn't scroll
horizontally
- Scrollable columns render separately with independent scroll state
- Horizontal scroll offset adjustments for proper column resize handle
positioning with pinned sections
- Pinned section stays at viewport left edge while scrollable section
scrolls independently
- Supports 0 < pinned_cols < total_cols (partial pinning)
- Applied to CSV preview for better UX with wide datasets

## Context

Part of CSV preview feature series, following PR zed-industries#53496 (settings UI).

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] ~~Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)~~
no ui changes besides pinning itself. UI improvements out of scope of
this PR

Release Notes:

- Improved CSV preview with column pinning to keep identifiers visible
while scrolling

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
## Summary

Adds column pinning (freeze) capability to data tables, allowing the
first N columns to remain visible while scrolling horizontally through
the rest of the table content.

Common spreadsheet/data table UX pattern. When viewing wide tables with
many columns, users need to see identifying information (row labels,
IDs) while scrolling right to explore data.

## Demo
Idle state:
<img width="559" height="179" alt="image"
src="https://github.com/user-attachments/assets/b3f89221-8aa9-4e8a-9a39-6f06cc8a4eea"
/>
Scrolled horizontally (name column dissapeared, line numbers column
stayed pinned):
<img width="522" height="174" alt="image"
src="https://github.com/user-attachments/assets/c6695a00-5e40-49b8-81d7-0b30e26bb7bb"
/>

## Implementation

- New `pin_cols(n: usize)` builder method on `Table` to specify how many
columns to pin
- Pinned columns render in a fixed section that doesn't scroll
horizontally
- Scrollable columns render separately with independent scroll state
- Horizontal scroll offset adjustments for proper column resize handle
positioning with pinned sections
- Pinned section stays at viewport left edge while scrollable section
scrolls independently
- Supports 0 < pinned_cols < total_cols (partial pinning)
- Applied to CSV preview for better UX with wide datasets

## Context

Part of CSV preview feature series, following PR zed-industries#53496 (settings UI).

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] ~~Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)~~
no ui changes besides pinning itself. UI improvements out of scope of
this PR

Release Notes:

- Improved CSV preview with column pinning to keep identifiers visible
while scrolling

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants