asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
341 stars 97 forks source link

Preview scroll offset wrong when working with tables #873

Open nogjam opened 7 months ago

nogjam commented 7 months ago

One of my primary motivations for using AsciiDoc is the great flexibility it allows with respect to tables. However, the VSCode preview has multiple issues when it comes to syncing between source code and preview.

The following screencast illustrates the issues in four stages:

  1. We try scrolling the source with the scroll wheel. The preview doesn't track at all.
  2. We try scrolling the source by holding the cursor down on the scrollbar. Again, the preview doesn't track at all.
  3. We try scrolling the preview with the scroll wheel. It keeps snapping back to the top of the table. This one is particularly frustrating.
  4. We try scrolling the preview with the cursor on the scrollbar. The source position lags behind the preview. Note also: the snapping behavior is still present, but mitigated by VSCode's default snap-to-cursor-scrollbar-position behavior.

AsciiDoctorVSCodePreviewTableScrolling.webm

Here is the source code I used to produce the screencast (apparently GitHub doesn't allow uploading .adoc files, so I changed the extension): PreviewTableScrollExample.txt

VSCode About: Version: 1.88.1 Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:34:12.840Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.2.0-32-generic

Extension Version (also seen at start of screencast): v3.2.3

Searching the logs for any occurrences of "asciidoctor-vscode", I found the following three messages. However, they do not occur in the time span when the above screencast was captured, which was 14:24.

2024-04-23 13:33:48.318 [info] ExtensionService#_doActivateExtension asciidoctor.asciidoctor-vscode, startup: false, activationEvent: 'onLanguage:asciidoc'

...

2024-04-23 13:52:26.445 [error] Error: [ExtensionListenerError] Extension 'asciidoctor.asciidoctor-vscode' FAILED to handle event: Error: Illegal value for `line`
    at o.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:162:20792)
    at s.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
    at s.z (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:729)
    at s.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:945)
    at D.$acceptModelChanged (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:152:75704)
    at u.S (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:5502)
    at u.Q (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:5268)
    at u.M (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:4361)
    at u.L (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:3440)
    at o.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:2227)
    at s.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
    at s.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:876)
    at r.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:107:14173)
    at o.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:175:8018)
    at s.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
    at s.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:876)
    at r.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:107:14173)
    at MessagePortMain.<anonymous> (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:175:6298)
    at MessagePortMain.emit (node:events:517:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2285)

...

2024-04-23 14:03:20.754 [error] Error: [ExtensionListenerError] Extension 'asciidoctor.asciidoctor-vscode' FAILED to handle event: Error: Illegal value for `line`
    at o.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:162:20792)
    at s.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
    at s.z (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:729)
    at s.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:945)
    at D.$acceptModelChanged (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:152:75704)
    at u.S (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:5502)
    at u.Q (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:5268)
    at u.M (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:4361)
    at u.L (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:3440)
    at o.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:149:2227)
    at s.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
    at s.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:876)
    at r.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:107:14173)
    at o.value (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:175:8018)
    at s.y (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:659)
    at s.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:82:876)
    at r.fire (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:107:14173)
    at MessagePortMain.<anonymous> (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:175:6298)
    at MessagePortMain.emit (node:events:517:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:2285)

I am a big fan of AsciiDoc and thank you for the work you put into this extension! :heart: I hope this helps improve its quality.

nogjam commented 7 months ago

Related: https://github.com/asciidoctor/asciidoctor-vscode/issues/869