[LyX/master] Improve Update::FitCursor when there is a selection

Scott Kostyshak skostysh at lyx.org
Sun Apr 12 15:37:54 UTC 2020


On Tue, Jan 07, 2020 at 09:56:28AM +0100, Jean-Marc Lasgouttes wrote:
> commit 294969c6a2ba456c231e52d79b4637cdd50a6a95
> Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
> Date:   Mon Jan 6 17:10:38 2020 +0100
> 
>     Improve Update::FitCursor when there is a selection
>     
>     It is better indeed to try to make the whole selection fit on screen.
>     
>     Fixes bug #11012.
> ---
>  src/BufferView.cpp |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/src/BufferView.cpp b/src/BufferView.cpp
> index 4495093..eda08ed 100644
> --- a/src/BufferView.cpp
> +++ b/src/BufferView.cpp
> @@ -527,7 +527,13 @@ void BufferView::processUpdateFlags(Update::flags flags)
>  	// Then make sure that the screen contains the cursor if needed
>  	if (flags & Update::FitCursor) {
>  		if (needsFitCursor()) {
> -			scrollToCursor(d->cursor_, false);
> +			// First try to make the selection start visible
> +			// (which is just the cursor when there is no selection)
> +			scrollToCursor(d->cursor_.selectionBegin(), false);
> +			// Is the cursor visible? (only useful if cursor is at end of selection)
> +			if (needsFitCursor())
> +				// then try to make cursor visible instead
> +				scrollToCursor(d->cursor_, false);
>  			// Metrics have to be recomputed (maybe again)
>  			updateMetrics(flags);
>  		}
> -- 

This seems to cause problems when scrolling with large insets. To
reproduce:

1. Open the attached mwe.23.lyx.
2. Scroll to bottom.
3. Zoom at least until the program listing takes up more than your
   screen.
4. Click on the area just below the program listing, in the LyX work
   area.

For me, LyX scrolls up above the top of the document. If you can't
reproduce, try one more time but zoom in even more.

Can you reproduce? 

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mwe.23.lyx
Type: application/x-lyx
Size: 4265 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200412/57e26183/attachment.lyx>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200412/57e26183/attachment.asc>


More information about the lyx-devel mailing list