How to reload an editor widget #8520
-
Hi, I have the following code : I've looked at how the FileResource manages this on file change but I can't understand how this all works. Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@MikaelDesharnais-ST I'm not sure I understand this comment:
I'm not sure what you mean by reloading the editor, editors correspond to a single file resource. If you require opening a new editor without having to close the old one then you would call the |
Beta Was this translation helpful? Give feedback.
-
To take another example, when you open a file in an editor, it gets updated when the file is changed. What I'm trying to achieve is the same thing but for some data stored in memory : Let's say I have a registry that stores some content to be displayed in an editor. If the content changes I would like to update the editor's content. |
Beta Was this translation helpful? Give feedback.
-
I've found the solution to my problem : I've created a new type of resource resolver for the following scheme : bmem-txt:// The resource extends MutableResource and fires fireDidChangeContents if a change is made in the registry. The implementation of the readContents method for this resource simply returns the content of the registry for the key corresponding to the URI map. Thus, for a specific URI, only one editor can be opened and if the content corresponding the URI is changed in the registry, the editor is reloaded. Even better, the scroll position seems to be kept (Great) ! The code that I finally found and that solved it all was in : packages\monaco\src\browser\monaco-editor-model.ts |
Beta Was this translation helpful? Give feedback.
I've found the solution to my problem :
I've created a new type of resource resolver for the following scheme : bmem-txt://
This resource is able to get data from a specific registry that acts like a basic hashmap<string,string> and fires event if a key is modified.
The resource extends MutableResource and fires fireDidChangeContents if a change is made in the registry. The implementation of the readContents method for this resource simply returns the content of the registry for the key corresponding to the URI map.
Thus, for a specific URI, only one editor can be opened and if the content corresponding the URI is changed in the registry, the editor is reloaded. Even better, the scroll po…