typst-preview.nvim
typst-preview.nvim copied to clipboard
[BUG] Cursor follow randomly breaks..
Before you start
- [X] You've headed over to tinymist and can confirm that the issue does not exist with the VS Code plugin for tinymist.
Describe the bug
Cursors are supposed to sync when clicked in the browser, but the behavior is inconsistent — it only occurs sporadically and does not trigger on every click. Additionally, when moving the cursor in the editor, the browser preview does not update to reflect the current position, which feels like a missing feature or potentially a bug.
To Reproduce
Steps to reproduce the behavior:
- Open a
.typfile in Neovim withtypst-preview.nvimenabled. - Launch the preview in the browser.
- Click at various locations in the preview.
- Observe that cursor sync with the editor is inconsistent.
- Move the cursor within the editor.
- Notice that the browser does not follow the cursor location.
Expected behavior
Clicking in the browser should consistently sync the cursor location back to Neovim. Similarly, when moving the cursor within Neovim, the browser preview should scroll or update accordingly to maintain synchronization.
Screenshots/Video Video: https://files.catbox.moe/o2zt7n.mp4 Debug Logs: https://0x0.st/8OJK.txt
Desktop (please complete the following information):
- OS: Fedora Linux 6.13.10-200.fc41.x86_64
- Plugin Information:
typst-preview.nvim- Version: 1.3.0
- Commit:
ddcc711 - Branch:
master - Source: chomosuke/typst-preview.nvim
Additional context
Log and video attachments provided. This behavior was observed using the tinymist backend. While this issue does not exist with the VS Code plugin for tinymist, it may be specific to the Neovim integration.
I've also this noticed while developing https://github.com/chomosuke/typst-preview.nvim/pull/88 but it seems that in the last iteration of that PR, cursor following works perfectly fine. One change that I made is to disable event suppression (which was performed for 100ms following each scroll event). Maybe that leads to missing important jump events? I'm not sure what the original motivation was for adding these timeouts.
May I have the typst file you tested with?
One thing it doesn't seem to like for some reason is adding multiple empty newlines to the end of a file
It also seems to dislike macros and/or files with lots of lines. I make a file, run :TypstPreview, type a bit, things work fine. I record a macro into register a that's just me entering insert mode, typing a few new lines. "Hi", and a few more new lines, then do 100@a, the plugin seems to have no idea what to do in terms of the cursor. All the "Hi"s do get rendered, but the scrolling gets confused. Also if I manage to get it to scroll down, usually by typing a few times, then do ggdG to delete everything, the preview does clear everything, but if I then start typing at the now only line in the file, while I think it is rendering the text, the scroll is not where I'm typing.
I'm using TinyMist v0.13.28, and the latest commit on this repo at the time I'm typing this, e544812bba84b4f7976590f2b6c0dfbd099e1893
Investigating some more. Running :TypstPreviewSyncCursor to make sure it tries that, and have the plugin's debug info on. scroll to line: 398, character: 0 is in there, so the plugin isn't suppressing it. I use Firefox to monitor the websocket, information is being sent to the browser. However, I am struggling to deserialize it at 3:30 AM. I'm thinking either this plugin is sending the data wrong, but somehow only sometimes, or tinymist is handling the data wrong, but again, somehow only sometimes.