Skip to content

Commit 272e8d7

Browse files
fix: replace null characters in copied monitor output
In OSes implementation of `clipboard.writeText`, null (`\u0000`) characters are parsed as string termination symbol, effectively truncating the copied output
1 parent 7efda98 commit 272e8d7

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)