fix: use the output buffer for Serial Monitor select-all and copy - #2936
Open
iblackscreen wants to merge 1 commit into
Open
iblackscreen wants to merge 1 commit into
iblackscreen wants to merge 1 commit into
Conversation
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
This branch was previously deployed
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.
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:
selection plus copy can only capture roughly one screen of data (Only the visible data can be copied from the serial Monitor #1081).
core.selectAllkeybinding, which selects the surroundingdocument instead of the monitor output (Missing "Select All" capability for Serial Monitor #812).
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 Outputtoolbar button that copies the internal line buffer. This PR connectsthe same buffer to the keyboard workflow users expect from IDE 1.x.
Change description
a new
serial-monitor-select-all-outputcommand, bound via a keybinding context that is onlyenabled while the output area has focus. The global select-all behavior everywhere else,
including the monitor's message input field, is untouched.
sanitizing as
Copy Output. The shared logic is extracted intolinesToPlainTextinmonitor-utils.ts.HTML to the clipboard (Content copied from Serial Monitor output is formatted text #2093).
active, incoming messages keep the selection alive.
shortcut targets it.
Other information
Copy Outputbutton. A manual mouse selection copies what is rendered, including timestamps ifthey are enabled. In both cases the clipboard receives plain text only.
not exist in the DOM, so a drag selection cannot reach them. Selecting everything is what
Ctrl/Cmd+A is for.
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