[gtksourceview] vim: fix ctrl+y/ctrl+e movements
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] vim: fix ctrl+y/ctrl+e movements
- Date: Tue, 23 Nov 2021 14:57:51 +0000 (UTC)
commit a88d46020e7fda3f0924879e61d7f18a616649b7
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 22 06:58:26 2021 -0800
vim: fix ctrl+y/ctrl+e movements
We only want to add to count in the forward direction. This fixes the
Ctrl+E moving two lines sometimes and the Ctrl+Y not moving at all.
This was an issue in gnome-text-editor, but not test-widget due to how
the rectangles play out (possibly due to margins).
gtksourceview/vim/gtksourcevimstate.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/vim/gtksourcevimstate.c b/gtksourceview/vim/gtksourcevimstate.c
index c0070c0b..530e50c0 100644
--- a/gtksourceview/vim/gtksourcevimstate.c
+++ b/gtksourceview/vim/gtksourcevimstate.c
@@ -724,12 +724,17 @@ gtk_source_vim_state_scroll_line (GtkSourceVimState *self,
view = gtk_source_vim_state_get_view (self);
gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (view), &rect);
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &top, rect.x, rect.y);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &top, 0, rect.y);
gtk_text_view_get_line_yrange (GTK_TEXT_VIEW (view), &top, &y, &height);
/* Add a line is slightly visible. Works in both directions */
- if (y < rect.y)
- count++;
+ if (y < rect.y && (rect.y - y) > (height / 2))
+ {
+ if (count > 0)
+ {
+ count++;
+ }
+ }
if (count > 0)
gtk_text_iter_forward_lines (&top, count);
@@ -773,7 +778,7 @@ scroll_half_page_up (GtkSourceVimState *self)
void
gtk_source_vim_state_scroll_half_page (GtkSourceVimState *self,
- int count)
+ int count)
{
GtkSourceView *view;
GdkRectangle rect, loc;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]