How to remove the decorations from the monaco?

Viewed 1048

I used "deltaDecorations" function to set some inline decorations dynamically according to some rules when the editor is open. But when editing the contents, I want to remove all the existed decorations and renew some decorations. It seems that the new decorations are always appended to the existed ones, even the ranges are the same. How can I remove all the existed decorations and set the new ones?

Thanks a lot.

1 Answers

Please see the following answer on Github.

Basically, the idea is that deltaDecorations function returns handles to those decorations, and if you want to get rid of the old ones, you need to provide those old handles to the new function call.

var decorations = [];
// returns decoration handles
decorations = editor.deltaDecorations(decorations, ....);
...
decorations = editor.deltaDecorations(decorations, ....);
Related