asciidoctor-vscode
asciidoctor-vscode copied to clipboard
With "refresh interval" 0 and "scroll preview with editor", preview jumps to cursor after save
I need to use a "refresh interval" of 0, because the default kills my laptop battery. In v. 3.1.3 of the extension, when I save changes, the preview jumps to a position that puts the line that the cursor is on at the top of the window. In practice, this means that the line that I am editing moves to the top of the preview window, regardless of how low it is in the editor (but if I put the cursor on another line before saving, the preview jumps to that line). This is irritating, as I generally need to see the lines above the one that I'm working on, especially when I'm deriving equations.
This bug does not occur if I disable "scroll preview with editor", but that feature is too useful to disable. On the other hand, that feature does at least allow me to restore the preview to the correct position by scrolling the editor slightly.
Versions 3.1.2 and 3.1.0 of the extension suffer from the same problem, but version 2.9.8 doesn't suffer from it, so I've reverted to that version.
It seems like you should be able to observe this bug with any .adoc
file that is long enough to have a scrollable preview. But you can use this file as an example, if you like.
Steps to Reproduce
- Set "refresh interval" to 0 and enable "scroll preview with editor".
- Split the editor.
- Open the preview in one side of the split.
- Scroll to the top of the editor window.
- Without scrolling, edit any line in (say) the bottom half of the editor window.
- Leave the cursor where it is and save.
System Information
Version: 1.80.2 Commit: 2ccd690cbff1569e4a83d7c43d45101f817401dc Date: 2023-07-27T20:41:52.615Z Electron: 22.3.14 ElectronBuildId: 22695494 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Linux x64 5.15.0-78-generic
I agree that the current behavior is odd!
I think we should define if we want to scroll the preview with the cursor. Currently, it does but only when you save the document. We could introduce an option to enable/disable this feature.
@OsePedro What do you think?
I personally wouldn't find a "scroll preview with cursor" feature useful, as:
- Rolling a mousewheel or sliding a trackpad is faster than moving to a line and clicking; and
- Putting the cursor on a line doesn't express anything about where the user wants that line to be in the preview window. So the extension would have to make an assumption (e.g. assume that the user wants the active line to be at the top of the preview), which will often be wrong.
Putting the cursor on a line doesn't express anything about where the user wants that line to be in the preview window. So the extension would have to make an assumption (e.g. assume that the user wants the active line to be at the top of the preview), which will often be wrong.
I agree. In that case, we should revert this behavior. I don't think it was intended but rather a side effect.
I have the exact same problem symptom, but I would say it's even more annoying because:
- The preview jumps immediately upon refresh after an edit, even without saving
- My refresh interval setting is at the default
2000
I don't see what's the use of scrolling the preview based on the line being edited.
Version: 1.85.1 (user setup) Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2 Date: 2023-12-13T09:49:37.021Z Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19045