Revert "CodeEditor: Ensure latest onChange callback is called" (#83677)

Revert "CodeEditor: Ensure latest onChange callback is called (#83599)"

This reverts commit 3363e3f2d3.
This commit is contained in:
Josh Hunt 2024-02-29 11:40:11 +00:00 committed by GitHub
parent f0822e0aef
commit 0fd46a1bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,7 +102,7 @@ class UnthemedCodeEditor extends PureComponent<Props> {
}; };
handleOnMount = (editor: MonacoEditorType, monaco: Monaco) => { handleOnMount = (editor: MonacoEditorType, monaco: Monaco) => {
const { getSuggestions, language, onEditorDidMount } = this.props; const { getSuggestions, language, onChange, onEditorDidMount } = this.props;
this.modelId = editor.getModel()?.id; this.modelId = editor.getModel()?.id;
this.getEditorValue = () => editor.getValue(); this.getEditorValue = () => editor.getValue();
@ -119,21 +119,15 @@ class UnthemedCodeEditor extends PureComponent<Props> {
} }
}); });
editor.getModel()?.onDidChangeContent(this.handleChangeContent); if (onChange) {
editor.getModel()?.onDidChangeContent(() => onChange(editor.getValue()));
}
if (onEditorDidMount) { if (onEditorDidMount) {
onEditorDidMount(editor, monaco); onEditorDidMount(editor, monaco);
} }
}; };
handleChangeContent = () => {
const { onChange } = this.props;
if (onChange) {
onChange(this.getEditorValue());
}
};
render() { render() {
const { theme, language, width, height, showMiniMap, showLineNumbers, readOnly, monacoOptions } = this.props; const { theme, language, width, height, showMiniMap, showLineNumbers, readOnly, monacoOptions } = this.props;
const { alwaysConsumeMouseWheel, ...restMonacoOptions } = monacoOptions ?? {}; const { alwaysConsumeMouseWheel, ...restMonacoOptions } = monacoOptions ?? {};