fregante / GhostText

👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).
https://GhostText.fregante.com
MIT License
3.25k stars 116 forks source link

Unable to use on CompilerExplorer/godbolt.org (Monaco Editor) #283

Closed iamkroot closed 2 days ago

iamkroot commented 1 year ago

Hello! Thanks for this cool extension! I am unable to use GT with Compiler Explorer. It uses the Monaco editor under the hood (#239). Upon activating GT, it does detect the textarea, and my editor (sublime) also prints some logs saying it has connected. But no file is opened inside the editor. Any idea why this would be happening?

fregante commented 1 year ago

Thanks for the report! It looks like the initialization is failing for some reason. On this line this.field is undefined

https://github.com/fregante/GhostText/blob/2874463cb1ab184077a7a3b25fe6ad1117bafdcb/source/ghost-text.js#L156

and I think it's because this line throws an error in their own code:

https://github.com/fregante/GhostText/blob/2874463cb1ab184077a7a3b25fe6ad1117bafdcb/source/ghost-text.js#L39-L43

Screenshot

I think it's their own "Sentry" error reporter.

An easy solution would be to make that dispatchEvent call asynchronous so it doesn't affect the constructor. Or better yet wrap it in try/catch

However that isn't guarantee to fix it since it's their code that is breaking it. It might be worth contacting https://sentry.io, they might know why their code is throwing an error in a basic dispatchEvent