[gtksourceview/wip/chergert/vim] fix jump to line with #G



commit bc7c1cec89b13508365373a187169a3b89daba7a
Author: Christian Hergert <chergert redhat com>
Date:   Sat Oct 30 15:46:26 2021 -0700

    fix jump to line with #G

 gtksourceview/vim/gtk-source-vim-motion.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index a24e0ed0..77536075 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -1150,6 +1150,30 @@ motion_next_scroll_line (GtkTextIter        *iter,
        return TRUE;
 }
 
+static gboolean
+motion_line_number (GtkTextIter        *iter,
+                    GtkSourceVimMotion *self)
+{
+       int count = gtk_source_vim_state_get_count (GTK_SOURCE_VIM_STATE (self));
+
+       if (self->apply_count != 1)
+               return FALSE;
+
+       if (count > 0)
+               count--;
+
+       gtk_text_iter_set_line (iter, count);
+
+       while (!gtk_text_iter_ends_line (iter) &&
+              g_unichar_isspace (gtk_text_iter_get_char (iter)) &&
+              gtk_text_iter_forward_char (iter))
+       {
+               /* Do Nothing */
+       }
+
+       return TRUE;
+}
+
 GtkSourceVimState *
 gtk_source_vim_motion_new (void)
 {
@@ -1319,6 +1343,8 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                        return gtk_source_vim_motion_complete (self, motion_prev_line_visual_column, 
INCLUSIVE);
 
                case GDK_KEY_G:
+                       if (gtk_source_vim_state_get_count_set (state))
+                               return gtk_source_vim_motion_complete (self, motion_line_number, INCLUSIVE);
                        return gtk_source_vim_motion_complete (self, motion_last_line_first_char, EXCLUSIVE);
 
                case GDK_KEY_g:


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