How to save the decorations in monaco editor

176 Views Asked by At

I am using monaco editor in my web application. I have added BookmarkGlyphMarginClass to bookmark certain lines in monaco editor. My scenario goes like this : In my application, on a screen I have 2 panes. The left pane contains a list and on click of any item in the left pane , the respective content opens up in the right pane which is a monaco editor. So in the right pane I had bookmarked certain lines. Next I click on second link, now the monaco editor shows contents related to the second link. Now if I again click on the first link , the lines that I had bookmarked previously is not retained. All the bookmarks have been removed. How to retain the previous bookmarks.

I'm working with normal jsp's and I'm expecting jquery side changes.

1

There are 1 best solutions below

0
On BEST ANSWER

The decorations are automatically deleted when you switch to a different editor model, so you have to store the marked line numbers/ranges somewhere and re-do the decoration creation every time your editor gets another model.