-
Notifications
You must be signed in to change notification settings - Fork 3.6k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
How to scope the editor models / typescriptDefaults
#1105
Comments
typescriptDefaults
This is outside the scope of the One alternative idea to cheat would be to think about user focus... i.e. an user can only work with at most 1 editor at a time. So you can use a different language id, e.g. Then, you can defined a monarch colorizer for Good luck! |
Okay, thanks for the info that this scenario is not supported at the moment. About the thing with the second language id ("ts2"): Is what you mean with the "ts2" language a "fake" language without semantic model, but just a syntax highlighting enabled editor? => No error squiggles in the (non-focused) "ts2" editors, only in the focused "typescript" editor. And when changing the focus between the editors, I also need to switch the global editor models (dispose all, and create them for the focused editor). |
Yes
No, I think you just need to implement the following: editors.forEach(function(editor) {
editor.onDidBlurEditorWidget(() => {
monaco.editor.setModelLanguage(editor.getModel(), 'ts2')
});
editor.onDidFocusEditorWidget(() => {
monaco.editor.setModelLanguage(editor.getModel(), 'typescript')
});
}); I'm not sure how well it's gonna work, but this is the cheapest I can think of to simulate something similar to what you describe. |
@alexandrudima Each of my editors has a different (only partially overlapping) set of editor models (the one it displays and N non-visible/dependency models). This is why I think it's necessary to dispose all current editor models and loading "the current set" when switching focus. => To completely isolate them (avoid conflicts of duplicate type definitions, model URLs, ...). |
👍 Ok, I didn't know that. |
@alexandrudima Again thanks for your support. |
Anybody get this to work? Im putting in a tabbed editor, (where you write seperate non related snippets of ts that control automation tasks) and changing the models language doest seem to remove it from being used by the language server? and I still get "cannot redeclare ... etc". The approach is similar to above, set all models to plaintext on tab change, except the tab your changing too - which you set back to ts. All the relevant events fire and indicate that all models have changed - so I dont think its as much me doing it wrong as it not being supported? Ive looked at dispose removes the model from use in the language server like I want, and I could use this - but I would like to keep the undo history on tab change, and I cant see a way of doing this when you dispose all models and create the new model for the new tab each time. Thanks, would love any other ideas for this |
Any news on this topic? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I've tried it at StackOverflow, but had no luck...
Any chance advise to scope the changes to
monaco.languages.typescript
or the "editor models".Background: I want to host multiple Monaco editors with different sets of models (maybe also different
typescriptDefaults
).The text was updated successfully, but these errors were encountered: