-
Notifications
You must be signed in to change notification settings - Fork 207
Reverse scroll (scrolling the preview will also scroll source) #674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ReText/webenginepreview.py
Outdated
| self.editBox.resized.connect(self._handleEditorResized) | ||
|
|
||
| # When preview is scrolled, update the editor scroll accordingly | ||
| if hasattr(webPage, 'scrollPositionChanged'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This signal was introduced in Qt 5.7, and we require Qt 6. Maybe the if is not needed?
And the same below on line 236.
ReText/syncscroll.py
Outdated
| min_index = 0 | ||
| max_index = len(posmap_lines) - 1 | ||
| while max_index - min_index > 1: | ||
| current_index = int((min_index + max_index) / 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the // operator here, I guess?
| current_index = int((min_index + max_index) / 2) | |
| current_index = (min_index + max_index) // 2 |
|
Sorry for the delay with reviewing this (I was one week out, and another week keeping up with backlog). I tested this with various files, and it mostly looks good. However, on this file I see an interesting behavior: When you open live preview and try to scroll the editor panel, it gets stuck around line 5663: attempt to scroll below this line results in both editor and preview being reverted back to the same position. Maybe it's because the posmap sequence goes down at one point: <p data-posmap="5656">Entity definition:</p>
<pre class="literal-block" data-posmap="5678">(#PCDATA | <a class="reference internal" href="#inline-elements-1">%inline.elements</a>;)*</pre>
<p data-posmap="5662">The <span class="docutils literal">%text.model</span> parameter entity is directly employed in the content
models of the following elements: <a class="reference internal" href="#abbreviation"><abbreviation></a>,Any chance you can do something about this? P.S. if you changed operator |
|
I found a fix that now also handles your big document really nicely. |
|
Tried your new version: it still gets stuck around line 5617, it is possible to get past it when scrolling fast, but when scrolling the editor at normal speed, it keeps reverting to the same place. See the video below: first half of the video scrolling works fine, in the second half it keeps reverting to the old position. To me it looks like the new scroll position of the preview panel propagates back to the editor, which should not happen when you are scrolling the editor. Because of the same behavior, when scrolling the editor it is “flickering”, the scrolling is not smooth. Kazam_screencast_00006.mp4 |
|
I hope, this commit fixes it. I tested with doctree.rst and I was not able to observe similar flickering events. |
|
Excellent, thank you very much! |
i want to scroll in preview, too and it will synchronize back the scroll position to source code view