[gnome-builder] scroll-offset: handle odd/even number of visible lines differently



commit 7064b6ad0f606f9db821dd7963d1e394bf9b975a
Author: Christian Hergert <christian hergert me>
Date:   Tue Apr 7 12:51:04 2015 -0700

    scroll-offset: handle odd/even number of visible lines differently
    
    When we have an even number of visible lines, we could accidentally allow
    too many lines to be in the visible rect. So special case this situation
    and adjust the visible area appropriately.

 libide/ide-source-view.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 05d53c3..2d1ec7f 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -6307,6 +6307,14 @@ ide_source_view_get_visible_rect (IdeSourceView *self,
       area.height -= (2 * scroll_offset_height);
 
       /*
+       * If we have an even number of visible lines and scrolloffset is less than our
+       * desired scrolloffset, we need to remove an extra line so we don't have two
+       * visible lines.
+       */
+      if ((scroll_offset < priv->scroll_offset) && (visible_lines & 1) == 0)
+        area.height -= priv->cached_char_height;
+
+      /*
        * Use a multiple of the line height so we don't jump around when
        * focusing the last line (due to Y2 not fitting in the visible area).
        */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]