Repository navigation
data_table: Extend a cell range with Shift and the arrow keys - #4183
Merged
Merged
Conversation
With `cellRangeSelectable`, Shift with the arrows, Page Up, Page Down, Home and End now moves the end of the cell range and keeps its start and active cell, as a Shift-press already does. A single cell starts a range at itself, a range whose end comes back to its start is the cell again, and the end stops at the table's edges instead of wrapping. The moving end is kept in view. Closes #4176 Agent: rust-maintainer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
The two failing checks are not from this change (it only touches DataTable):
|
Member
Author
|
✅ LGTM: Shift+Arrow/Page/Home/End extend the cell range like Shift-click, bound only with
Reviewed head |
Member
Author
huacnlee
added a commit
that referenced
this pull request
Dec 3, 2026
Follow-up to #4177 / #4183. ## Problem On macOS, Cmd+C reaches a focused DataTable's `mod+c` binding (the keymap monitor matches before menu key equivalents), but choosing **Edit > Copy** with the mouse sends `copy:` to the root view, which only runs `text::copy` (selected text). With a table focused nothing is copied, and the item is still enabled. Platform check: | Platform | Menu Copy before | After | | --- | --- | --- | | macOS | `copy:` on the root → selected text only | bindings of Cmd+C first, then selected text | | Linux | `clipboard.copy` action on the GTK focus widget; NSH views other than text / selectable views have none → nothing | bindings of Ctrl+C first, then the widget's action | | Windows | already replays Ctrl+C through `input::key` → `keymap::key` | unchanged | ## Change The Edit menu's commands run the bindings their standard key has where the focus is, exactly as pressing the key does, then fall back to the default. - **macOS** (`view.rs`, `keymap.rs`) - `copy:` / `selectAll:` on NSH's root view try the Cmd+C / Cmd+A bindings first (`keymap::command`, sharing the focus rules of `keymap::pressed` via a new private `focus_in`). - New `cut:` / `paste:` on the root run the Cmd+X / Cmd+V bindings (e.g. an editor's); there was no handler before, so with no binding they stay disabled as today. - `validateMenuItem:` enables Copy only when a binding or selected text takes it, and Cut / Paste only when a binding does (AppKit's native "nothing to copy" state). - When a key-down is in flight, the menu action skips the bindings: the keyboard monitor already ran them, so a pass-through binding is not reported twice. - **Linux** (`chrome.rs`, `keymap.rs`): the edit roles run the Ctrl+key bindings (`keymap::press`, no longer dev-only) before activating `clipboard.*` / `selection.select-all` on the focus widget. Edit roles register no accelerators on Linux, so this path only runs for a menu click or `Menu.perform`. **Public API:** none. No new public items in `nsh-core` or the platform crates; this only changes what the platform-built Edit menu (and `Menu.perform`) does, matching the keyboard. ## Tests - New native check `tests/native/menu_copy.rs` (`NSH_MENU_COPY_CHECK_ONLY=1 cargo test -p nsh-platform-macos --test native -- --ignored`): with `mod+c` / `mod+v` bound, the root enables Copy / Paste and disables Cut; sending `copy:` / `paste:` fires the bindings once; with an `NSTextView` focused, Copy stays the field's and the binding is not offered. Fails on `main` (the root has no `validateMenuItem:`), passes here. - Unit tests (macOS and Linux `keymap.rs`): the menu keystroke of Copy / Cut / Paste / Select All equals `Keystroke::parse("mod+c" …)`, the form bindings use. - `NSH_KEYBOARD_CHECK_ONLY=1` native check passes; `cargo clippy -p nsh-platform-macos --tests` clean for the changed files. Not verified locally: Linux (the crate only builds on Linux; CI covers compile + unit tests), and a real menu-bar click in an unlocked session. 🤖 Generated with [Claude Code](https://claude.com/claude-code) 🤖 [Noop](https://huacnlee.github.io/noop) (rust-maintainer) · AI agent acting for @huacnlee Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
huacnlee
added a commit
that referenced
this pull request
Dec 3, 2026
) Main currently fails two Clippy jobs on every PR (seen on #4183 and #4194): - `check (macos-15)` (`cargo clippy -p nsh-macos-app --no-default-features --features js`): `hosted_content_loading`, `WebHost::busy` and the `loading` field are never used. They only serve `Surface::animating`, which is `#[cfg(feature = "dev")]` (added in #4151). - `web` (`cargo clippy ... --target wasm32-unknown-unknown`): `MemoryCache::insert_transient` is never used. Its only caller is the decoder, which the web target does not build (added in #4152). Changes: - Build `hosted_content_loading` and `WebHost::busy` only with `dev`, and allow the `loading` field (still written by the navigation delegate) to go unread without `dev`. - Allow `insert_transient` to be unused on wasm32, as `access.rs` already does for its web-only dead code. No behavior or public API change. Verification: CI on this PR (the two failing jobs above). A local single-core Clippy run did not finish in time on a loaded host. 🤖 Generated with [Claude Code](https://claude.com/claude-code) 🤖 [Noop](https://huacnlee.github.io/noop) (rust-maintainer) · AI agent acting for @huacnlee Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4176
Description
With
cellSelectableandcellRangeSelectable, a cell range could only be made with the pointer (drag or Shift-press). Shift with the arrow keys was not bound, so a keyboard user could not make or change a range.Shift with the arrows, Page Up, Page Down, Home and End now moves the range's end and keeps its start and active cell, the same model a Shift-press already uses (and the one spreadsheets use):
loopSelectiondoes not make a range jump to the other side.cellRangeSelectable; tables without it see no change.GPUI Kit's table has no cell ranges, so there is no Kit interaction to match; the behavior follows the existing Shift-press path in this component.
#4177 (Copy on a range copies only the active cell) was already fixed on main by #3955, after 0.8.0. The new tests here also cover it from the keyboard: a range grown with Shift+arrow, including a reversed one and one crossing a fixed-right column, copies its cells as TSV from the top-left cell in display order.
Known gap: Edit > Copy from the menu bar (macOS)
Cmd+C reaches the table: NSH's key monitor matches the table's
mod+cbinding before AppKit's menu key equivalents. Choosing Edit > Copy with the mouse does not: the item'scopy:goes to the root view, which only copies text selections (nsh-platform-macos/src/view.rs→text::copy), so with a table focused it copies nothing while the item stays enabled. Routing a menu role to the focused component is a cross-platform change of its own and is not part of this PR.Screenshot
macOS, real window (
nsh test --target macos, the gallery fixture after Shift+Down, Shift+Right ×2, Shift+Up ×2:sel=1,1>0,3). The Mac this ran on was locked, so the picture is drawn in process and does not show the range highlight; the test asserts the selection and the clipboard text on the real platform.Public API
None. Behavior change only: Shift + arrow / Page Up / Page Down / Home / End with
cellRangeSelectableon.How to Test
Nav::extend): growing, reversing, Home/End/Page, keeping an app-given active cell, edges without wrap, shrinking back to the cell, and the plain fallback.Chosen range 0,1 to 1,1/Chosen range 2,2 to 1,1never shows) and pass with this change; all 32 DataTable Rust tests pass.Checklist
🤖 Generated with Claude Code
🤖 Noop (rust-maintainer) · Opus 5.5 acting for @huacnlee