diff --git a/src/model/workbench/panel.tsx b/src/model/workbench/panel.tsx index e48ebde33..b863e487d 100644 --- a/src/model/workbench/panel.tsx +++ b/src/model/workbench/panel.tsx @@ -39,12 +39,18 @@ export function builtInOutputPanel() { data: '', }; - function onUpdateEditorIns(editorInstance: IStandaloneCodeEditor) { - outputPane.outputEditorInstance = editorInstance; + function onUpdateEditorIns( + editorInstance: IStandaloneCodeEditor, + item: IOutput + ) { + item.outputEditorInstance = editorInstance; } outputPane.renderPane = (item) => ( - + onUpdateEditorIns(instance, item)} + {...item} + /> ); return outputPane; diff --git a/src/services/workbench/panelService.ts b/src/services/workbench/panelService.ts index 9684bf4d3..e769e3003 100644 --- a/src/services/workbench/panelService.ts +++ b/src/services/workbench/panelService.ts @@ -102,6 +102,10 @@ export class PanelService extends Component implements IPanelService { public appendOutput(content: string): void { const outputValue = this.outputEditorInstance?.getValue(); + this.updateOutput({ + id: PANEL_OUTPUT, + data: outputValue + content, + }); this.outputEditorInstance?.setValue(outputValue + content); } diff --git a/src/workbench/panel/output.tsx b/src/workbench/panel/output.tsx index aade289bd..31964e015 100644 --- a/src/workbench/panel/output.tsx +++ b/src/workbench/panel/output.tsx @@ -6,7 +6,13 @@ import { MonacoEditor } from 'mo/components/monaco'; const defaultClassName = prefixClaName('output'); function Output(props: IOutput) { - const { id, data = '', onUpdateEditorIns } = props; + const { id, data = '', onUpdateEditorIns, outputEditorInstance } = props; + const editorDidMount = React.useRef(false); + + if (!editorDidMount.current && outputEditorInstance) { + outputEditorInstance.dispose(); + } + return (
{ onUpdateEditorIns?.(editorInstance); + editorDidMount.current = true; }} />