Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type information 'leaking' between models #308

Closed
jjhuff opened this issue Nov 10, 2021 · 2 comments
Closed

Type information 'leaking' between models #308

jjhuff opened this issue Nov 10, 2021 · 2 comments

Comments

@jjhuff
Copy link

jjhuff commented Nov 10, 2021

Describe the bug
When using multiple models, type info seems to 'leak' between models/editor instances

To Reproduce
Sandbox: https://codesandbox.io/s/multi-model-editor-forked-hig6i
Steps to reproduce the behavior:

  1. Toggle between script1.js and script2.js
  2. Start typing bar under script1.js
  3. Notice that you get bar as a suggestion

Expected behavior
Models should be isolated

Desktop (please complete the following information):

  • Version: Appears in 4.3.1 but not 4.0.4
@suren-atoyan
Copy link
Owner

Hey @jjhuff 👋

I've just checked the snippet, and yes, you are right, the issue exists. But I also tried to reproduce it in the monaco-playground to be sure if the issue related to the react wrapper or to the original package. And it seems the issue is related to the original package. To reproduce it try the code below in the above-mentioned playground.

const model1 = monaco.editor.createModel(`
const foo=1;
`, 'javascript', 'root/js/file1.js');

const model2 = monaco.editor.createModel(`
const foo=2;
const bar=3;
`, 'javascript', 'root/js/file2.js');

const editor = monaco.editor.create(document.getElementById('container'), {
    model: model1,
});

setTimeout(() => {
  editor.setModel(model2);
}, 500);

setTimeout(() => {
  editor.setModel(model1);
}, 1000);

@jjhuff
Copy link
Author

jjhuff commented Nov 20, 2021

Awesome, thanks for the playground snippet! I filed over on the main project.

@jjhuff jjhuff closed this as completed Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants