[gtksourceview/wip/chergert/vim] improve movements for braces/parents



commit 183a1cb3db084a08b888cdcca5b97305eea3bffa
Author: Christian Hergert <chergert redhat com>
Date:   Sun Nov 7 09:12:45 2021 -0800

    improve movements for braces/parents

 gtksourceview/vim/gtk-source-vim-motion.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index c4e5c78a..d8a08114 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -1475,23 +1475,41 @@ static gboolean
 motion_bracket (GtkTextIter        *iter,
                 GtkSourceVimMotion *self)
 {
+       GtkTextIter orig = *iter;
+
        if (self->bracket_left)
        {
+               gtk_text_iter_backward_char (iter);
+
                if (self->f_char == '(')
-                       return gtk_source_vim_iter_backward_block_paren_start (iter);
+               {
+                       if (gtk_source_vim_iter_backward_block_paren_start (iter))
+                               return TRUE;
+               }
 
                if (self->f_char == '{')
-                       return gtk_source_vim_iter_backward_block_brace_start (iter);
+               {
+                       if (gtk_source_vim_iter_backward_block_brace_start (iter))
+                               return TRUE;
+               }
        }
        else
        {
                if (self->f_char == ')')
-                       return gtk_source_vim_iter_forward_block_paren_end (iter);
+               {
+                       if (gtk_source_vim_iter_forward_block_paren_end (iter))
+                               return TRUE;
+               }
 
                if (self->f_char == '}')
-                       return gtk_source_vim_iter_forward_block_brace_end (iter);
+               {
+                       if (gtk_source_vim_iter_forward_block_brace_end (iter))
+                               return TRUE;
+               }
        }
 
+       *iter = orig;
+
        return FALSE;
 }
 


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