mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Improve painless validation handling in monaco (#105799)
This commit is contained in:
parent
71385b6944
commit
d3ccb982c7
1 changed files with 8 additions and 0 deletions
|
@ -35,6 +35,11 @@ export class DiagnosticsAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
// Reset the model markers if an empty string is provided on change
|
||||
if (model.getValue().trim() === '') {
|
||||
return monaco.editor.setModelMarkers(model, ID, []);
|
||||
}
|
||||
|
||||
// Every time a new change is made, wait 500ms before validating
|
||||
clearTimeout(handle);
|
||||
handle = setTimeout(() => this.validate(model.uri), 500);
|
||||
|
@ -42,8 +47,11 @@ export class DiagnosticsAdapter {
|
|||
|
||||
model.onDidChangeLanguage(({ newLanguage }) => {
|
||||
// Reset the model markers if the language ID has changed and is no longer "painless"
|
||||
// Otherwise, re-validate
|
||||
if (newLanguage !== ID) {
|
||||
return monaco.editor.setModelMarkers(model, ID, []);
|
||||
} else {
|
||||
this.validate(model.uri);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue