Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead

Home Page:https://Enter-tainer.github.io/typst-preview/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not follow cursor in Vim mode

dag-h opened this issue · comments

Describe the bug
When using the built-in Vim mode in VS Code, the preview does not follow the cursor, only if clicking the code.

To Reproduce

  1. Activate Vim mode in VS Code
  2. Start preview
  3. Move the cursor using Vim movement keys

Expected behavior
The preview should move with the cursor.

Package/Software version:

VSCode version(Help -> About):

Version: 1.85.2
Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
Date: 2024-01-18T06:40:19.222Z
Electron: 25.9.7
ElectronBuildId: 26354273
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 5.14.0-362.13.1.el9_3.x86_64

typst-preview extension version:

Name: Typst Preview
Id: mgt19937.typst-preview
Description: preview your typst document in instant
Version: 0.10.6
Publisher: mgt19937
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview

iirc it also dont track cursor in non-vim mode without clicking

we may allow user customize this: sync preview when keyboard/mouse triggered selection change. currently we only respond to mouse events

That would be great, as I never use the mouse for navigation. I think that goes for most people who use the Vim mode.

There is a finished branch, https://github.com/Enter-tainer/typst-preview/tree/scroll-sync-by-keyboard
But I'm not sure whether you will like it, because typst doesn't provide perfect span, so it doesn't scroll your content smoothly.

There is also another solution, you can bind a shortcut to typst-preview.sync, and stroke the key to scroll content. I believe you mostly do writing in a same page.

{
"command": "typst-preview.sync",
"title": "Typst Preview: Sync preview with current cursor",
"description": "Scroll preview to current cursor position",
"icon": "$(sync)",
"when": "resourceLangId == typst && editorTextFocus"
},

But I'm not sure whether you will like it, because typst doesn't provide perfect span, so it doesn't scroll your content smoothly.

After testing a bit, I recall that the blocker of this feature, scrolling content by keyboard events, is not inperfect spans, but inaccurate scrolling. Though it is not quite perfect, the scroll-sync-by-keyboard branch is ready to merge and use since we had improved accuracy of scrolling content.

The new variant of typst-preview.scrollSync, onSelectionChange, is introduced in #233.

The previous onSelectionChange mode is renamed to onSelectionChangeByMouse, and the new variant which make scrolloSync follow both mouse and cursor is named onSelectionChange.

close since #233