monaco-react icon indicating copy to clipboard operation
monaco-react copied to clipboard

Possible bug when creating multiple models

Open Xoffio opened this issue 4 years ago • 0 comments

Describe the bug

I'm trying to use the multi-editor code to edit multiple files. I'm making a hook where I save all the tabs, and each tab's information. If the tab list is empty then I don't render the Editor

If I have multiple files open then I edit them and later I close them When I reopen them seems like the disposeEditor is not disposing all the models so some data persist and one gets lost. usually the last one to be close.

I know I'm not too clear so I'll show you how to reproduce it.

To Reproduce

Steps to reproduce the behavior:

  1. Here I have a code that I made to show the problem.

Imagine that the three first button are files on a bar. So every time they get click a new tab opens.

  1. Open the three files br01-01

  2. Modify each of them. Let's say: 1 for the first file, 2 for the second one, and 3 for the last one. br01-02

  3. Then close all of them until the Editor closes as well.

  4. Re-open each of then.

Here you will notice that one of the files is going to lose the data. These does not happens when keepCurrentModel is set to true

I think it has something to do with the function disposeEditor

Expected behavior

when re-open the files I expect that all the files get erase or that the data of all of them is preserve.

Desktop (please complete the following information):

  • OS: Windows10
  • Browser: Chrome
  • Version [e.g. 22]

Note: I think this is a possible bug or I am using the library wrong.

Xoffio avatar Aug 05 '21 22:08 Xoffio