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

[BUG]: error A document must have at least one line #156

Closed
oeyoews opened this issue Jan 10, 2024 · 11 comments
Closed

[BUG]: error A document must have at least one line #156

oeyoews opened this issue Jan 10, 2024 · 11 comments

Comments

@oeyoews
Copy link

oeyoews commented Jan 10, 2024

I made codemirror6 into a tiddlywiki plugin, and added the codemirror-vim extension. Everything works very well, whether it is hosted locally or online https://oeyoews.github.io/tiddlywiki-codemirror6/#%24%3A%2Fplugins%2Foeyoews%2Ftiddlywiki-codemirror-6

But on tiddlyhost's hosting website (https://cm6-bug-on-tiddlyhost.tiddlyhost.com), I encountered the following error. I am not sure whether it is a problem with tiddlyhost or codemirror-vim.

Screenity.video.-.Jan.10.2024.mp4

Steps to reproduce: Enter xxx, select and delete them all and the problem in the video will be triggered.

@nightwing
Copy link
Collaborator

This does not seem to be related to codemirror-vim, because deleting text in insert mode is handled by codemirror itself, not by vim plugin.

@oeyoews
Copy link
Author

oeyoews commented Jan 10, 2024

But if cm6 does not enable vim mode, there will be no such problem.

@oeyoews
Copy link
Author

oeyoews commented Jan 10, 2024

Screenity.video.-.Jan.10.2024.1.mp4

@nightwing
Copy link
Collaborator

is there a way to load https://cm6-bug-on-tiddlyhost.tiddlyhost.com/ with non-minimized code?

@oeyoews
Copy link
Author

oeyoews commented Jan 10, 2024

tiddly-gittly/Modern.TiddlyDev#60, I tried it, and there seems to be something wrong with this packaged framework.

@nightwing
Copy link
Collaborator

One part of the issue is that LineBreakPlaceholder = "\uffff"; is turned to kn = ""; in minification, leading to "".split("") returning [], while "".split("\uffff") would return [""].

Another part, which may explain why the issue does not happen without vim, is that applyDOMChange in codemirror is being triggered when deleting text even though in other places it is being handled directly from delete keypress, but i did not figure out yet why is that happening.

@oeyoews
Copy link
Author

oeyoews commented Jan 10, 2024

For additional information, if press enter to nextline on vim insert tmode, codemirror6 editor not update(These problems will not be triggered when running locally or on the github web pages, which is very strange)

@oeyoews oeyoews changed the title {BUG]: error A document must have at least one line [BUG]: error A document must have at least one line Jan 10, 2024
@nightwing
Copy link
Collaborator

Looks like when adding vim keymap you are removing the https://codemirror.net/docs/ref/#commands.standardKeymap so commands added by it like Backspace, Delete or Enter are missing.

@oeyoews
Copy link
Author

oeyoews commented Jan 11, 2024

Indeed, when opening vimmode, I did not add defaultkeymap, which caused an error. Now I have fixed it, but what I am most curious about is why this bug is not triggered locally or on other websites. It only occurs on tiddlyhost

@pmario
Copy link

pmario commented Jan 11, 2024

@oeyoews can this issue be closed here?

@oeyoews oeyoews closed this as completed Jan 11, 2024
@nightwing
Copy link
Collaborator

Most likely locally you don't have LineBreakPlaceholder bug, so pressing enter there would work as it does on contenteditable node, but would not indent code.

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

3 participants