]> git.lyx.org Git - features.git/commitdiff
Improve Update::FitCursor when there is a selection
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 6 Jan 2020 16:10:38 +0000 (17:10 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:50 +0000 (15:48 +0200)
It is better indeed to try to make the whole selection fit on screen.

Fixes bug #11012.

src/BufferView.cpp

index 4495093cf2b3356a0fb1495e497ce1e1672a8719..eda08ed6f97aa8b8b1feca0d529a8fe1b4af8a78 100644 (file)
@@ -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);
                }