-
-
Notifications
You must be signed in to change notification settings - Fork 347
feat(inspector): insert columns left/right and delete selected columns in the CSV editor #1940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // | ||
| // InspectorColumnTargets.swift | ||
| // TablePro | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum InspectorColumnTargets { | ||
| static func deleteMenuSelection(clicked: Int, fullySelected: IndexSet) -> [Int] { | ||
| guard fullySelected.contains(clicked), fullySelected.count > 1 else { return [clicked] } | ||
| return fullySelected.sorted() | ||
| } | ||
|
|
||
| static func deleteTargets(explicit: [Int]?, fullySelected: IndexSet, columnCount: Int) -> [Int] { | ||
| let candidates = explicit ?? Array(fullySelected) | ||
| return candidates.filter { $0 >= 0 && $0 < columnCount }.sorted() | ||
| } | ||
|
|
||
| static func insertAnchor(clicked: Int?, fullySelected: IndexSet, columnCount: Int, toRight: Bool) -> Int? { | ||
| guard columnCount > 0 else { return nil } | ||
| if let clicked, clicked >= 0, clicked < columnCount { | ||
| return clicked | ||
| } | ||
| if let bound = toRight ? fullySelected.max() : fullySelected.min(), bound >= 0, bound < columnCount { | ||
| return bound | ||
| } | ||
| return toRight ? columnCount - 1 : 0 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,18 @@ final class GridSelectionController { | |
| update(.single(rect, anchor: anchor, active: anchor)) | ||
| } | ||
|
|
||
| func addEntireColumn(_ column: Int, totalRows: Int) { | ||
| guard column >= 0, totalRows > 0 else { return } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an empty CSV is open (or the current filter produces no visible rows), Cmd-clicking headers cannot build a multi-column selection because this returns without updating Useful? React with 👍 / 👎. |
||
| let rect = GridRect(rows: 0...(totalRows - 1), columns: column...column) | ||
| let anchor = GridCoord(row: 0, column: column) | ||
| let addition = GridSelection.single(rect, anchor: anchor, active: anchor) | ||
| update(selection.isEmpty ? addition : selection.union(addition)) | ||
| } | ||
|
|
||
| func selectedFullColumns() -> IndexSet { | ||
| fullySelectedColumns(in: selection) | ||
| } | ||
|
|
||
| func selectEntireRow(_ row: Int, totalColumns: Int) { | ||
| guard row >= 0, totalColumns > 0 else { return } | ||
| let rect = GridRect(rows: row...row, columns: 0...(totalColumns - 1)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After Cmd-clicking multiple headers, opening the toolbar
Columnsmenu and choosing Delete for one of those columns still deletes only that one: this explicit[index]payload takes precedence over the grid selection incolumnDeleteTargets. The header context menu correctly supplies the multi-column target set, but the toolbar is documented as exposing the same submenu, so this route silently bypasses the new multi-column delete behavior.Useful? React with 👍 / 👎.