retext-project / retext

ReText: Simple but powerful editor for Markdown and reStructuredText
GNU General Public License v2.0
1.88k stars 196 forks source link

Synchronised scrolling is not bidirectional between panes #621

Open donjan opened 1 year ago

donjan commented 1 year ago

Using ReText 7.2.3 on Ubuntu 22.04.

Enabled the WebKit renderer option, as well as Preferences -> Enable synchronized scrolling for Markdown. With live preview on.

Observed behaviour

Scrolling in the editor pane synchronises the live preview. Scrolling in the live preview render does not scroll synchronise the editor, which stays still.

In large documents, when something to improve is found by scrolling through the preview, finding the location in the editor is tedious. Moving the mouse to the editor pane and starting to scroll immediately loses the point of interest in the preview.

Expected behaviour

Scrolling in either pane should synchronise the other.

A less convenient but functional alternative might be a "go to current location in editor" context menu in the preview.

Additional info

Issue https://github.com/retext-project/retext/issues/108 requests "sync, no matter in which window the user scrolls" and is marked as closed, but doesn't match the expected behaviour. Issue https://github.com/retext-project/retext/issues/513 is still open but the comment history doesn't clarify directionality.

https://github.com/retext-project/retext/blob/master/ReText/syncscroll.py gives the impression that only the direction editor->preview is implemented.

donjan commented 1 year ago

Thinking some more about it, here are two additional possible workarounds:

  1. Disable scrolling in the right pane. Always moving the mouse to the left pane requires minimal adaptation and guides the user into avoiding the issue. Probably easy to implement.
  2. Disconnect scrolling from moving the content in the right pane and apply it to the left pane instead. I.e. scrolling in either pane scrolls the left one, which then synchronises the right one. Provides unified scrolling feeling.
donjan commented 1 year ago

Now switched to Retext 8.0.1, issue as described in OP persists.

donjan commented 7 months ago

In webenginepreview.py::ReTextWebEnginePreview, only the editBox (left side) is hooked up to events. We can hook up the preview (right side) to events (after the variable webPage is defined in the constructor):

webPage.scrollPositionChanged.connect(lambda value: print(value))

But as mentioned, SyncScroll is currently not equipped to update the editor window.