Files
zed/crates/csv_preview/src/settings.rs
T
Oleksandr KholiavkoandAnthony Eid 45ea641c6a csv_preview: Add independently resizable columns (#53295)
This PR adds spreadsheet-style independently resizable columns (dragging
changes total table width) and fixes scrolling issues in variable list
mode.

**What changed:**

- Adds `ResizableColumnsState` struct for independently resizable
columns (spreadsheet-style)
- Adds `ColumnWidthConfig::Resizable` variant for spreadsheet mode
- Adds `DraggedResizableColumn` drag payload type
- Adds `ResizableHeaderInfo` for double-click-to-reset functionality
- Adds `render_resize_handles_resizable` function for resize handles
rendering
- Adds horizontal scroll handle to `TableInteractionState`
- Adds `.on_drag_move::<DraggedResizableColumn>` handler to Table for
drag resizing

**Bug fixes:**

- Fixed missing vertical scrollbar in variable list mode
- Fixed half-broken scrolling in variable list mode (added
.measure_all() to make scrollbar aware of the height of the table)
- Moved vertical scrollbar to be pinned at the right side of the pane
with table — previously it was attached to the table content and was
pushed off-screen when table content was too wide

**API addition:**

```rust
// New variant added:
pub enum ColumnWidthConfig {
    Static { widths: StaticColumnWidths, table_width: Option<DefiniteLength> },
    Redistributable { entity: Entity<RedistributableColumnsState>, table_width: Option<DefiniteLength> },
    Resizable(Entity<ResizableColumnsState>),  // NEW: spreadsheet-style
}
```

**Callers updated:**

- csv_preview: Changed from `ColumnWidthConfig::redistributable()` to
use new resizable mode
- git_graph: Added `resizable_info` parameter

**Context:**

This is part 3 of a 3-PR series improving data table column width
handling:

1. [#51059](https://github.com/zed-industries/zed/pull/51059) - Extract
modules into separate files (mechanical change)
2. [#51120](https://github.com/zed-industries/zed/pull/51120) -
Introduce width config enum for redistributable column widths (API
rework)
3. **This PR**: Add independently resizable columns + fix variable list
scrolling (new feature + bug fixes)

The series builds on previously merged infrastructure:

- [#46341](https://github.com/zed-industries/zed/pull/46341) - Data
table dynamic column support
- [#46190](https://github.com/zed-industries/zed/pull/46190) - Variable
row height mode for data tables

Primary beneficiary: CSV preview feature
([#48207](https://github.com/zed-industries/zed/pull/48207))

This work is based on the [original draft PR
#44344](https://github.com/zed-industries/zed/pull/44344), decomposed
into reviewable pieces.

-----

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
2026-04-08 07:24:37 +00:00

47 lines
1.2 KiB
Rust

#[derive(Default, Clone, Copy)]
pub enum RowRenderMechanism {
/// More correct for multiline content, but slower.
#[allow(dead_code)] // Will be used when settings ui is added
VariableList,
/// Default behaviour for now while resizable columns are being stabilized.
#[default]
UniformList,
}
#[derive(Default, Clone, Copy)]
pub enum VerticalAlignment {
/// Align text to the top of cells
#[default]
Top,
/// Center text vertically in cells
Center,
}
#[derive(Default, Clone, Copy)]
pub enum FontType {
/// Use the default UI font
#[default]
Ui,
/// Use monospace font (same as buffer/editor font)
Monospace,
}
#[derive(Default, Clone, Copy)]
pub enum RowIdentifiers {
/// Show original line numbers from CSV file
#[default]
SrcLines,
/// Show sequential row numbers starting from 1
RowNum,
}
#[derive(Clone, Default)]
pub(crate) struct CsvPreviewSettings {
pub(crate) rendering_with: RowRenderMechanism,
pub(crate) vertical_alignment: VerticalAlignment,
pub(crate) font_type: FontType,
pub(crate) numbering_type: RowIdentifiers,
pub(crate) show_debug_info: bool,
pub(crate) multiline_cells_enabled: bool,
}