mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-25 20:26:38 +00:00
From now on, monitor widget does not expect EOL.
Otherwise, if client code does not contain `Serial.write('\n')`, the widget does not show any output. Closes arduino/arduino-pro-ide#201 Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
807b2ad424
commit
5c16f8d6c9
@ -288,17 +288,20 @@ export class SerialMonitorOutput extends React.Component<SerialMonitorOutput.Pro
|
|||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
let chunk = '';
|
|
||||||
this.toDisposeBeforeUnmount.pushAll([
|
this.toDisposeBeforeUnmount.pushAll([
|
||||||
this.props.monitorConnection.onRead(({ data }) => {
|
this.props.monitorConnection.onRead(({ data }) => {
|
||||||
chunk += data;
|
const rawLines = data.split('\n');
|
||||||
const eolIndex = chunk.indexOf('\n');
|
const lines: string[] = []
|
||||||
if (eolIndex !== -1) {
|
const timestamp = () => this.state.timestamp ? `${dateFormat(new Date(), 'H:M:ss.l')} -> ` : '';
|
||||||
const line = chunk.substring(0, eolIndex + 1);
|
for (let i = 0; i < rawLines.length; i++) {
|
||||||
chunk = chunk.slice(eolIndex + 1);
|
if (i === 0 && this.state.content.length !== 0) {
|
||||||
const content = `${this.state.content}${this.state.timestamp ? `${dateFormat(new Date(), 'H:M:ss.l')} -> ` : ''}${line}`;
|
lines.push(rawLines[i]);
|
||||||
this.setState({ content });
|
} else {
|
||||||
|
lines.push(timestamp() + rawLines[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
const content = this.state.content + lines.join('\n');
|
||||||
|
this.setState({ content });
|
||||||
}),
|
}),
|
||||||
this.props.clearConsoleEvent(() => this.setState({ content: '' })),
|
this.props.clearConsoleEvent(() => this.setState({ content: '' })),
|
||||||
this.props.monitorModel.onChange(({ property }) => {
|
this.props.monitorModel.onChange(({ property }) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user