From 5f0153cca87ee1a1358d145287843908c801d9c4 Mon Sep 17 00:00:00 2001 From: Rich Chiodo Date: Mon, 14 Jan 2019 16:13:33 -0800 Subject: [PATCH] Fix problem Ian found with the collapse/expand in the codemirror (#3983) * Fix problem Ian found with the collapse/expand in the codemirror * No need to check for null --- src/datascience-ui/history-react/code.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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(); + } + } }