Skip to content

Commit

Permalink
[Code] fix editor lifecycle method (#31983)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedragon authored and mw-ding committed Feb 26, 2019
1 parent 22d64d9 commit 126eac4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions x-pack/plugins/code/public/components/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,26 @@ export class EditorComponent extends React.Component<IProps> {
this.revealPosition(this.props.revealPosition);
}
const { file } = this.props;
const currentFileContent = this.props.file.content;
if (file.content && file.content !== currentFileContent) {
if (file.content && prevProps.file.content !== file.content) {
const { uri, path, revision } = file.payload;
this.loadText(file.content, uri, path, file.lang!, revision).then(() => {
if (this.props.revealPosition) {
this.revealPosition(this.props.revealPosition);
}
});
}
if (prevProps.showBlame !== this.props.showBlame && this.props.showBlame) {
this.loadBlame(this.props.blames);
this.monaco!.editor!.updateOptions({ lineHeight: 38 });
} else if (!this.props.showBlame) {
this.destroyBlameWidgets();
this.monaco!.editor!.updateOptions({ lineHeight: 24 });
}
if (prevProps.blames !== this.props.blames && this.props.showBlame) {
this.loadBlame(this.props.blames);
this.monaco!.editor!.updateOptions({ lineHeight: 38 });
if (this.monaco && this.monaco.editor) {
if (prevProps.showBlame !== this.props.showBlame && this.props.showBlame) {
this.loadBlame(this.props.blames);
this.monaco.editor.updateOptions({ lineHeight: 38 });
} else if (!this.props.showBlame) {
this.destroyBlameWidgets();
this.monaco.editor.updateOptions({ lineHeight: 24 });
}
if (prevProps.blames !== this.props.blames && this.props.showBlame) {
this.loadBlame(this.props.blames);
this.monaco.editor.updateOptions({ lineHeight: 38 });
}
}
}

Expand Down

0 comments on commit 126eac4

Please sign in to comment.