# csv_preview: Implement data_table columns pining \(\#56619\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/dca5976f82a6816f126cbab2cb16568a7c173fcf)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: dca5976f82a6816f126cbab2cb16568a7c173fcf

Requested commit: dca5976f82a6816f126cbab2cb16568a7c173fcf

Commit: dca5976f82a6816f126cbab2cb16568a7c173fcf

Tree: 8d6d8f473f0e3650e52ac7283e05ab2153bbc531

Author: Oleksandr Kholiavko

Committer: GitHub

## Message

```
csv_preview: Implement data_table columns pining (#56619)

## 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 #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>
```

## Parents

- [bf68bf79ffc2a35c7647dfa18a9b2a23c6209d9b](https://git.cafe/gitcafe/zed/commit/bf68bf79ffc2a35c7647dfa18a9b2a23c6209d9b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/dca5976f82a6816f126cbab2cb16568a7c173fcf?format=markdown)
