Skip to content

DataTable: Copy on a cell range copies only the active cell #4177

Backlog

Description

@5at15h

Description

With a range of cells selected in DataTable, Copy puts only the range's active cell on the clipboard, not the cells of the range.

Environment

  • NSH: 0.8.0 (nsh-base 0.8.0 from crates.io)
  • Platform: macOS, desktop
  • How it runs: embedded in an app (Rust API), also under the headless test driver

Steps to Reproduce

A data_table with cell and range selection on, then:

  1. Click a cell, Shift-click the cell one row down and one column right (a 2×2 range).
  2. Press Cmd+C.
  3. Paste somewhere.

Expected

Every cell of the range: a tab between cells and a line break between rows, in the displayed column order. That is the form selection_text already writes for a row (tabs) and a column (line breaks).

Actual

One cell. nsh-base-0.8.0/src/data_table/controller.rs, selection_text (lines 2033-2041):

Selection::Range(range) => {
    let active = range.active_cell();
    self.write_cell(active.row as usize, active.column as usize, &mut text);
}

Related, from reading the source: on macOS the standard Copy menu role appears to reach text Copy rather than the table's (nsh-platform-macos-0.8.0/src/view.rs:966, src/text.rs:2863), so Edit > Copy with a table focused needs the app to handle the item itself.

The fix looks small (loop the range's rows and its columns in columns.order(), as the row and column arms do). Happy to send a pull request if that is welcome.

Activity

  1. huacnlee commented on Dec 3, 2026

    @huacnlee
    Member

    Thanks for the detailed report. This is fixed on main by #3955 (merged after 0.8.0): Copy (the shortcut and DataTableRef.copy() / DataTableApi::copy()) now writes the whole range as tab-separated rows, starting at the top-left cell and in displayed column order, with cells that contain tabs, line breaks or quotes quoted. It will ship in the next release.

    #4183 adds Shift+arrow range extension (#4176) and tests that grow a range from the keyboard, including a reversed one and one across a fixed column, then check the copied text.

    On the macOS menu point: you read it right. Cmd+C reaches the table, because NSH's key monitor matches the table's mod+c binding before AppKit's menu key equivalents. Choosing Edit > Copy with the mouse goes to the root view's copy:, which only copies text selections, so with a table focused it copies nothing. That is tracked separately; until then, an app that wants the menu item to copy a focused table can handle the item itself and call copy() on the table's ref.

    🤖 Noop (rust-maintainer) · Opus 5.5 acting for @huacnlee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions