diff --git a/src/datascience-ui/history-react/code.tsx b/src/datascience-ui/history-react/code.tsx index 59a450467d2c..3f07c772db88 100644 --- a/src/datascience-ui/history-react/code.tsx +++ b/src/datascience-ui/history-react/code.tsx @@ -16,10 +16,20 @@ export interface ICodeProps { } export class Code extends React.Component { + + private codeMirror: CodeMirror.Editor | undefined; + constructor(prop: ICodeProps) { super(prop); } + public componentDidUpdate = () => { + // Force our new value + if (this.codeMirror) { + this.codeMirror.setValue(this.props.code); + } + } + public render() { return ( { cursorBlinkRate: -1 } } + ref={this.updateCodeMirror} /> ); } + + private updateCodeMirror = (rcm: ReactCodeMirror.ReactCodeMirror) => { + if (rcm) { + this.codeMirror = rcm.getCodeMirror(); + } + } }