Skip to content

Commit

Permalink
Fix problem Ian found with the collapse/expand in the codemirror (#3983)
Browse files Browse the repository at this point in the history
* Fix problem Ian found with the collapse/expand in the codemirror

* No need to check for null
  • Loading branch information
rchiodo authored Jan 15, 2019
1 parent 0df057b commit 5f0153c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/datascience-ui/history-react/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ export interface ICodeProps {
}

export class Code extends React.Component<ICodeProps> {

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 (
<RCM
Expand All @@ -35,7 +45,14 @@ export class Code extends React.Component<ICodeProps> {
cursorBlinkRate: -1
}
}
ref={this.updateCodeMirror}
/>
);
}

private updateCodeMirror = (rcm: ReactCodeMirror.ReactCodeMirror) => {
if (rcm) {
this.codeMirror = rcm.getCodeMirror();
}
}
}

0 comments on commit 5f0153c

Please sign in to comment.