1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix: always use string for monaco.editor.setValue(value) / handle undefined

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-10-09 17:24:43 +03:00
parent 5093b094f6
commit adbe6cad69

View File

@ -244,15 +244,15 @@ export class MonacoEditor extends React.Component<MonacoEditorProps> {
return editor.createModel(value, language, uri); return editor.createModel(value, language, uri);
} }
setValue(value: string) { setValue(value = "") {
if (value == this.getValue()) return; if (value == this.getValue()) return;
this.editor.setValue(value); this.editor.setValue(value);
this.validateOnChange(value); this.validateOnChange(value);
} }
getValue(opts?: { preserveBOM: boolean; lineEnding: string; }) { getValue(opts?: { preserveBOM: boolean; lineEnding: string; }): string {
return this.editor.getValue(opts); return this.editor?.getValue(opts) ?? "";
} }
// avoid excessive validations during typing // avoid excessive validations during typing