feat(inspector): switch the CSV first row between header and data#1942
Conversation
9b42ef2 to
8faf1f6
Compare
745f56a to
ba0d32f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba0d32fd69
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let firstCells = cells(forRow: 0) | ||
| logicalRows.removeFirst() | ||
| columnNames = firstCells | ||
| headerRef = .materialized(firstCells) |
There was a problem hiding this comment.
Keep promoted header cells in sync with column edits
After promoting a headerless CSV and then adding or removing a column without toggling the header back off, this stores the promoted header as a fixed headerRef while insertColumn/removeColumn update only columnNames and data rows. CSVWriter subsequently writes that stale header source, so, for example, promoting 1,2\n3,4\n, adding column c, and saving produces a two-cell header followed by three-cell data rows; the new column name is lost and the saved CSV has mismatched widths.
Useful? React with 👍 / 👎.
|
Addressed a code review. Findings and fixes:
|
8faf1f6 to
9dd6e93
Compare
ba0d32f to
ef9a509
Compare
9dd6e93 to
d22b41d
Compare
ef9a509 to
216a906
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 216a9068ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @objc func inspectorToggleHeaderRow(_ sender: Any?) { | ||
| inspectorDocument?.toggleHeaderRow() |
There was a problem hiding this comment.
Clear row selection when toggling the header
When a row is selected, this action changes the backing row indices but leaves state.selectedRowIndices intact. For example, with an unfiltered CSV, selecting the first data row and demoting the header inserts a new row at index 0; invoking Delete Selected Rows then deletes the former header row rather than the row that was selected before the toggle. Clear or rebase the selection before refreshing the grid.
Useful? React with 👍 / 👎.
216a906 to
e3eb043
Compare
…wire Cmd+Shift+H through shortcuts
e3eb043 to
140e8ea
Compare
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Part 4 of 4 toward #1469 (CSV structural editing). The header/data toggle. Stacked on #1941 (base branch
feat/1469-csv-split-merge).What
Cmd+Shift+H) flips whether the first row is a header. Turning the header off moves it into the data and names columnsColumn 1,Column 2, ...; turning it back on promotes the first data row to the header. Undoable.Column 1,Column 2,...header line. This also fixes byte round-trip for headerless files.Why
Auto-detection guesses whether row one is a header. When it guesses wrong, "Delete Column" and every other structural verb operate on the wrong interpretation, and (before this) saving a headerless file silently added a synthetic header. #1469 calls this out: without a header toggle, delete-column semantics are ambiguous.
How (native / HIG)
CSVRowStoregains an explicithasHeaderRowflag (set from the same detection used at open) andtoggleHeaderRow(), which moves the header row in or out of the data set and reindexes column names.CSVWriternow emits the header row only whenhasHeaderRowis true, so the on-disk file matches the current header state and headerless files round-trip byte-for-byte.hasHeaderRowis part of the snapshot). Inferred types are recomputed.Cmd+Shift+His free in TablePro and not a macOS reserved shortcut (Finder uses it for Go > Home, which is app-scoped). The Edit-menu item is gated on the CSV window being frontmost.toggleHeaderRow()is added toInspectorDocumentwith a default no-op (additive PluginKit change, no version bump).Tests
CSVRowStore.toggleHeaderRow: header to data, data to header, and a two-toggle round-trip.CSVWriter: a headerless file writes with no synthetic header row (byte-for-byte round-trip).Docs / changelog
docs/features/csv-inspector.mdxnew Header row section;docs/features/keyboard-shortcuts.mdxaddsCmd+Shift+H.[Unreleased].Needs a local Xcode build to confirm compilation. PluginKit change is additive; no version bump.