[gnome-builder] gb-editor-vim: Fix scroll off



commit 0ce39ef58ede2834366b3be0ca962ae33110e47e
Author: Carlos Soriano <carlos soriano89 gmail com>
Date:   Sat Oct 4 11:43:26 2014 +0200

    gb-editor-vim: Fix scroll off
    
    rect.y + rect.height is actually the line after the last one, no the
    last one.
    Decrease by one more the scroll off when going a page down.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737877

 src/editor/gb-editor-vim.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 69cf010..d8746f2 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -17,6 +17,7 @@
  */
 
 #define G_LOG_DOMAIN "vim"
+#define SCROLL_OFF 3
 
 #include <errno.h>
 #include <glib/gi18n.h>
@@ -1797,7 +1798,7 @@ gb_editor_vim_page_up (GbEditorVim *vim)
   gtk_text_view_get_iter_at_location (vim->priv->text_view, &iter,
                                       rect.x, rect.y);
 
-  line = MAX (0, gtk_text_iter_get_line (&iter) + 3);
+  line = MAX (0, gtk_text_iter_get_line (&iter) + SCROLL_OFF);
   gtk_text_iter_set_line (&iter, line);
 
   for (offset = vim->priv->target_line_offset; offset; offset--)
@@ -1821,13 +1822,14 @@ gb_editor_vim_page_down (GbEditorVim *vim)
   gtk_text_view_get_iter_at_location (vim->priv->text_view, &iter,
                                       rect.x, rect.y + rect.height);
 
-  line = MAX (0, gtk_text_iter_get_line (&iter) - 3);
+  // rect.y + rect.height is the next line affter the end of the buffer so
+  // now we have to decrease one more.
+  line = MAX (0, gtk_text_iter_get_line (&iter) - SCROLL_OFF - 1);
   gtk_text_iter_set_line (&iter, line);
 
   for (offset = vim->priv->target_line_offset; offset; offset--)
     if (gtk_text_iter_ends_line (&iter) || !gtk_text_iter_forward_char (&iter))
       break;
-
   gb_editor_vim_move_to_iter (vim, &iter, 0.0);
 }
 


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