Skip to content

fix: use the output buffer for Serial Monitor select-all and copy - #2936

Open
iblackscreen wants to merge 1 commit into
arduino:mainfrom
iblackscreen:fix/serial-monitor-copy-buffer
Open

iblackscreen wants to merge 1 commit into
arduino:mainfrom
iblackscreen:fix/serial-monitor-copy-buffer

Conversation

@iblackscreen

Copy link
Copy Markdown

Motivation

In IDE 1.x users could click into the Serial Monitor, press Ctrl+A and then Ctrl+C to copy the
whole output. In IDE 2.x this is not possible:

This matters in education: schools and universities use Arduinos as low-cost measurement
instruments in physics classes, and copying a recorded measurement series out of the Serial
Monitor is a routine step there (several comments on #812 describe classroom use).

#2718 added a Copy Output toolbar button that copies the internal line buffer. This PR connects
the same buffer to the keyboard workflow users expect from IDE 1.x.

Change description

  • Click into the Serial Monitor output and press Ctrl/Cmd+A: the output area is selected. This is
    a new serial-monitor-select-all-output command, bound via a keybinding context that is only
    enabled while the output area has focus. The global select-all behavior everywhere else,
    including the monitor's message input field, is untouched.
  • Ctrl/Cmd+C then copies the complete buffered output as plain text, with the same null-character
    sanitizing as Copy Output. The shared logic is extracted into linesToPlainText in
    monitor-utils.ts.
  • Copying a manual mouse selection inside the output now writes plain text instead of formatted
    HTML to the clipboard (Content copied from Serial Monitor output is formatted text #2093).
  • The select-all state is cleared on click or when the output area loses focus. While it is
    active, incoming messages keep the selection alive.
  • The focusable output area shows a themed focus outline, so keyboard users can see that the
    shortcut targets it.

Other information

  • The copied "select all" content is the raw buffer without timestamps, identical to the
    Copy Output button. A manual mouse selection copies what is rendered, including timestamps if
    they are enabled. In both cases the clipboard receives plain text only.
  • Mouse selection is still limited to the rendered rows: lines that are scrolled out of view do
    not exist in the DOM, so a drag selection cannot reach them. Selecting everything is what
    Ctrl/Cmd+A is for.
  • feat(serial-monitor): replace virtual list with textarea for native text selection #2885 addresses the same issues by replacing the virtualized list with a read-only textarea.
    That gives native selection, but it re-renders the whole buffer on every message batch, which
    is the problem the virtualization was introduced for, and it loses the timestamp rendering.
    This PR keeps the virtualized list and the timestamps and only wires the existing buffer to the
    expected shortcuts.

Fixes #812
Refs #1081, #2093

In IDE 1.x, users could click into the Serial Monitor, press Ctrl/Cmd+A and then Ctrl/Cmd+C to copy the
whole output. In IDE 2.x the output is virtualized with react-window, so only the visible rows exist in
the DOM: mouse selection cannot reach more than one screen of data, Ctrl/Cmd+A selects the surrounding
document instead, and copied content arrives as formatted HTML.

This change wires the keyboard workflow to the internal line buffer that already backs the Copy Output
toolbar button (arduino#2718):

- Ctrl/Cmd+A selects the output area via a new serial-monitor-select-all-output command, bound through a
  keybinding context that is only enabled while the output area has focus. The global select-all behavior
  everywhere else, including the monitor's message input field, is untouched.
- Ctrl/Cmd+C then copies the complete buffered output as plain text, with the same null-character
  sanitizing as Copy Output (extracted into the shared helper linesToPlainText).
- Copying a manual mouse selection inside the output now writes plain text instead of formatted HTML.
- The focusable output area shows a themed focus outline for keyboard accessibility, and the monitor
  widget's output emitters are now disposed with the widget.

Refs arduino#812, arduino#1081, arduino#2093
@CLAassistant

CLAassistant commented Jul 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch was previously deployed

1 inactive deployment
production — 6f44e00c Deployed Jul 7, 2026 by iblackscreen via build-type-determination #5728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing "Select All" capability for Serial Monitor

2 participants