Skip to content

Conversation

@carli2
Copy link
Contributor

@carli2 carli2 commented Oct 5, 2025

i want to scroll in preview, too and it will synchronize back the scroll position to source code view

self.editBox.resized.connect(self._handleEditorResized)

# When preview is scrolled, update the editor scroll accordingly
if hasattr(webPage, 'scrollPositionChanged'):
Copy link
Member

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.

min_index = 0
max_index = len(posmap_lines) - 1
while max_index - min_index > 1:
current_index = int((min_index + max_index) / 2)
Copy link
Member

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?

Suggested change
current_index = int((min_index + max_index) / 2)
current_index = (min_index + max_index) // 2

@mitya57
Copy link
Member

mitya57 commented Oct 17, 2025

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:
https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docs/ref/doctree.rst?format=raw

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">&lt;abbreviation&gt;</a>,

Any chance you can do something about this?

P.S. if you changed operator / to //, there is no more need to wrap into int(), the result is already int.

@carli2
Copy link
Contributor Author

carli2 commented Oct 18, 2025

I found a fix that now also handles your big document really nicely.

@mitya57
Copy link
Member

mitya57 commented Oct 18, 2025

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

@carli2
Copy link
Contributor Author

carli2 commented Oct 18, 2025

I hope, this commit fixes it. I tested with doctree.rst and I was not able to observe similar flickering events.

@mitya57
Copy link
Member

mitya57 commented Oct 18, 2025

Excellent, thank you very much!

@mitya57 mitya57 merged commit 5d4cfa3 into retext-project:master Oct 18, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants