hawkerm / monaco-editor-uwp

A Windows Runtime Component wrapper around the web-based Monaco Editor.
MIT License
153 stars 36 forks source link

Can't have two instances on a page with different languages #58

Closed calloncampbell closed 2 years ago

calloncampbell commented 3 years ago

When I try to use different instances on a page control, both are set to the same language. Say the first instance is SQL and the second is JSON, when I run the app they're both JSON.

hawkerm commented 3 years ago

Hey @calloncampbell are you setting the CodeLanguage property or setting the Options with the Language? And in XAML or code-behind?

This could be related to #53 and #21

hawkerm commented 3 years ago

I was able to reproduce locally, at least with a packaged version. Going to see if I can test in debug and try and see what's going on. Will try setting with options over CodeLanguage and see if that makes a difference

calloncampbell commented 3 years ago

Hi @hawkerm I was setting the CodeLanguage in XAML.

I'll give the Options way a try and let you know.

hawkerm commented 2 years ago

Have it reproducing in the test app in the debugger. Definitely seems like the two editors are sharing an Options instance. Why that is, I'm not sure yet.

hawkerm commented 2 years ago

Staring right in the face:

https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L98

This creates a single object of the Options which is used for the default value for every control. Need to switch to PropertyMetadata.Create factory method to create a default value callback to create a new instance for each editor. Though tracking down other issues this is creating now for some reason...