diff --git a/apps/remix-ide/src/app/panels/terminal.js b/apps/remix-ide/src/app/panels/terminal.js index 0f358b2611..096dcb1ba6 100644 --- a/apps/remix-ide/src/app/panels/terminal.js +++ b/apps/remix-ide/src/app/panels/terminal.js @@ -104,21 +104,11 @@ class Terminal extends Plugin { logHtml (html) { this.logHtmlResponse.push(html.innerText) this.renderComponent() - this.resetLogHtml() - } - - resetLogHtml () { - this.logHtmlResponse = [] } log (message) { this.logResponse.push(message) this.renderComponent() - this.resetLog() - } - - resetLog () { - this.logResponse = [] } render () { diff --git a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx index 8b729f07d4..e6a38e2058 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -68,6 +68,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { commandHistoryIndex: 0 }) + const [logState, setLogState] = useState({ + logIndex: 0, + htmlLogIndex: 0 + }) + const [searchInput, setSearchInput] = useState('') const [showTableHash, setShowTableHash] = useState([]) @@ -84,12 +89,18 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { } useEffect(() => { - scriptRunnerDispatch({ type: 'html', payload: { message: logHtmlResponse } }) - }, [logHtmlResponse]) + if (logHtmlResponse.length > 0) { + scriptRunnerDispatch({ type: 'html', payload: { message: logHtmlResponse.slice(logState.htmlLogIndex) } }) + setLogState(prevState => ({ ...prevState, htmlLogIndex: logHtmlResponse.length })) + } + }, [logHtmlResponse.length]) useEffect(() => { - scriptRunnerDispatch({ type: 'log', payload: { message: logResponse } }) - }, [logResponse]) + if (logResponse.length > 0) { + scriptRunnerDispatch({ type: 'log', payload: { message: logResponse.slice(logState.logIndex) } }) + setLogState(prevState => ({ ...prevState, logIndex: logResponse.length })) + } + }, [logResponse.length]) // events useEffect(() => {