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

CodeMirror 6 only works on the first connection, then a reload is required #296

Open
fregante opened this issue Oct 7, 2023 · 4 comments

Comments

@fregante
Copy link
Owner

fregante commented Oct 7, 2023

Setup

Browser: Safari, Chrome
Editor: VS Code, Emacs

Description

  1. Open https://ghosttext.fregante.com/test/#codemirror-6
  2. Activate CM6 field
  3. Type something in either direction
  4. Disconnect in any way
  5. Activate CM6 field again

No changes are transmitted from this point forward

@atodoron
Copy link

The issue is also present in Mozilla Firefox 132.0 with Emacs.

@atodoron
Copy link

A very stupid fix is to comment out the listener which waits for the gt:kill event from the codeMirror6 function.

I'm not sure what that part of the code is meant to do, but removing it lets you edit the cell multiple times without having to refresh the window.

Code change here: https://github.com/atodoron/GhostText/tree/CM6Errors for someone more familiar with the code base.

@fregante
Copy link
Owner Author

fregante commented Nov 11, 2024

I looked into the code. The fields are initialized once by calling function listener(field). This installs the two-way listeners for each field. The codeMirror6() initializer function though is set up in a way to ever be run once, because gt:kill aborts the AbortController and that removes all the listeners.

Now I don't remember why I decided to add gt:kill only to this field, but to fix the issue it would have to either be removed entirely or adjusted so it can be "restarted" somehow.

I think I'd have to re-architect the whole extension again to properly fix this, but for now maybe just removing gt:kill should work.

@atodoron maybe you can try

@flamingbear
Copy link

I don't know if it's right, but the first commit which gets rid of the 'gt:kill' listener completely is working well enough for me to stop using my work around macro in jupyter notebooks. 🙇 thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants