replit/codemirror-vim

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

oeyoews opened this issue · 11 comments

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.

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.

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

Screenity.video.-.Jan.10.2024.1.mp4

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

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

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.

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)

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.

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 commented

@oeyoews can this issue be closed here?

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.