Files
zed/crates/csv_preview/src/settings.rs
T
Oleksandr KholiavkoandAnthony Eid ef341146d2 csv_preview: Add settings UI panel with debug tools during development (#53496)
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

------

This PR adds a settings panel above the CSV table with dropdown menus to
control rendering behavior, and a performance metrics overlay for
debugging.

Currently it's mostly used for me during dev phase, but before release
of CSV preview feature all dev-only options will be cleaned up, and
future features like "copy selected" will have their settings in this
bar

<img width="2260" height="1674" alt="image_2026-04-09_11-52-24"
src="https://github.com/user-attachments/assets/9039fd59-5c46-4be4-9f33-b9825a3cdce3"
/>


**What changed:**

- Adds `render_settings_panel()` method with dropdown menus for:
- **Rendering Mode**: Variable Height (multiline support) vs Uniform
Height (better performance)
  - **Text Alignment**: Top vs Center vertical alignment within cells
- **Font Type**: UI Font vs Monospace for better readability (will be
exposed to user settings)
  - **Experimental**: Popover menu with toggles for debug features
- Adds `render_performance_metrics_overlay()` method showing:
  - CSV parsing duration
  - Rendered row count and indices
  - Positioned in bottom-right corner with semi-transparent styling

Context:
Will iterate on it with @Anthony-Eid 

Release Notes:

- N/A

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
2026-05-13 00:44:26 +00:00

39 lines
1.1 KiB
Rust

#[derive(Default, Clone, Copy, PartialEq)]
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 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) numbering_type: RowIdentifiers,
pub(crate) show_debug_info: bool,
#[cfg(feature = "dev-tools")]
pub(crate) show_perf_metrics_overlay: bool,
pub(crate) multiline_cells_enabled: bool,
}