avoid scrolling current line to top of view when start editing#794
avoid scrolling current line to top of view when start editing#794JFormDesigner wants to merge 1 commit intoFXMisc:masterfrom
Conversation
|
@JFormDesigner I'm not sure but I think that this is related to #777 (?), so I'm not going to merge this just yet. I'm having real heartache trying to resolve it properly though, as the solution I have causes chaos with undo at the moment. |
|
@JFormDesigner I believe it may be related because you reported that
So this sounds like there is a discrepancy between the contents of From your description I'm therefore guessing that this may also be the root cause of this issue, especially because calling |
This PR fixes a painful behavior that I noticed in Markdown Writer FX:
When I start typing into the current line, RichTextFX immediately
scrolls the current line to the top of the view.
Turns out that this happens only if embedded images feature is enabled
and if there are of course some embedded images before the current line.
The cause for the behaviour is in
GenericStyledArea.followCaret().For some unknown reason, the cell of the current line that is returned by
virtualFlow.getCell(parIdx)is not visible (cell.getNode().isVisible() == false)although it is visible on screen.
Later on in
Navigator.visit(MinDistanceTo targetPosition), the VirtualFlow stillthinks that is is not visible and invokes
Navigator.placeStartAtMayCrop()toscroll the current line to the top of the view.
The fix is easy:
virtualFlow.layout()Then we have a visible cell in
followCaret()and also later inNavigator.visit(MinDistanceTo targetPosition), which then invokesplaceToViewport()and scrolls only when really necessary.This PR probably fixes also issue #724, which describes the same strange behavior: