-
Hi again, i would like to know what the recommanded way of managing multiple models is for this API. Previously with the plain monaco-editor I created a model and stored in within a Map and when I wanted to change the active model then i used a modelId, manually created, searched for it in the Map and retrieved the values for the model and the model itself from there. The Map i used to store the models with their values and the modelID as the key:
The ModelState type:
and the methods i used to create and update the map and to set the activeModel:
For the scenario i don't have the VSCode environment like in the demo. I just have the editor with its model (and some services of course). The change of models is triggered outside of the editor in C#. Previously i did create a ModelState in C# and send it to typescript and used the methods i described up there. Now: When i create a model as described here (https://github.com/CodinGame/monaco-vscode-api?tab=readme-ov-file#model-creation) do i have to store the modelRef with the fileUri manually (like i did before in a Map) to be able to get the right model back when i change the active model? Assuming i get the modelRef i want based on the modelID, do i just have to call setModel from the IStandaloneEditor? Can you provide me a small example or some directions? Thank you very much. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Storing the model reference looks like a good replacement idea but you don't really need it, you can call createModelReference at any time, as soon as the file is registered in the virtual filesystem, and release it as soon as you don't need it directly Note that as soon as there at least one reference to a model, the model is considered "active" (so for instance, the LSP server will receive a didOpen on it) |
Beta Was this translation helpful? Give feedback.
Storing the model reference looks like a good replacement idea
but you don't really need it, you can call createModelReference at any time, as soon as the file is registered in the virtual filesystem, and release it as soon as you don't need it directly
Note that as soon as there at least one reference to a model, the model is considered "active" (so for instance, the LSP server will receive a didOpen on it)