Currently, I'm trying to remove model-markers from a Monaco-Model with the following approach.
monac.editor.getModelMarkers({owner: "owner"}).forEach(marker => {
console.log(marker)
marker.dispose()
})
Markers currently are set through the setModelMarker() method
monaco.editor.setModelMarkers(editor.getModel(), "owner", markers)
Setting an empty array to the Model override the model-markers, so this could be used as a workaround.
monaco.editor.setModelMarkers(editor.getModel(), "owner", [])
Is there any way how I could reliably remove model-markers
As pointed out in the comments,
getModelMarkers()returns an array of IMarker, which do not have adispose()method.For any modification of the marker set,
setModelMarkers()is the way.The main explanation is that
IMarkers are just interface object, which must thus have fields likeseverity,startLineNumber, etc.The Monaco editor uses a single
setModelMarkers()method to update the marker set, as any modification of these objects after calling the method will have no effect:With the same idea, you cannot delete a marker (with
delete markers[0];for example), as the delete operator deletes only a reference.