Skip to content

Commit 2bfd243

Browse files
fix: replace null characters in copied monitor output (#2832)
In some OSes implementation of `clipboard.writeText`, null (U+0000) characters are parsed as a string termination symbol, effectively truncating the copied output. We now replace null characters code with a visual representation (☐) to make string consistent cross platform.
1 parent 7efda98 commit 2bfd243

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arduino-ide-extension/src/browser/serial/monitor/serial-monitor-send-output.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ export class SerialMonitorOutput extends React.Component<
7575
this.props.clearConsoleEvent(() =>
7676
this.setState({ lines: [], charCount: 0 })
7777
),
78-
this.props.copyOutputEvent(() =>
79-
this.props.clipboardService.writeText(joinLines(this.state.lines))
80-
),
78+
this.props.copyOutputEvent(() => {
79+
const text = joinLines(this.state.lines);
80+
// Replace null characters with a visible symbol
81+
const safe = text.replace(/\u0000/g, '\u25A1');
82+
this.props.clipboardService.writeText(safe);
83+
}),
8184
this.props.monitorModel.onChange(({ property }) => {
8285
if (property === 'timestamp') {
8386
const { timestamp } = this.props.monitorModel;

0 commit comments

Comments
 (0)