[gtksourceview/wip/chergert/vim: 259/363] use replace-one command from normal mode




commit 8373a96a370570780e94bfe0d47f8285958f0e6f
Author: Christian Hergert <chergert redhat com>
Date:   Wed Nov 3 15:57:06 2021 -0700

    use replace-one command from normal mode

 gtksourceview/vim/gtk-source-vim-normal.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index f86296fb..2fdf9d6e 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -93,15 +93,31 @@ gtk_source_vim_normal_replace_one (GtkSourceVimNormal *self)
 {
        GtkSourceVimState *replace;
        GtkSourceVimState *char_pending;
+       GtkSourceVimState *motion;
+       GtkSourceVimState *selection_motion;
+       int count;
 
        g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
 
+       count = self->count, self->count = 0;
+
        char_pending = gtk_source_vim_char_pending_new ();
-       replace = gtk_source_vim_replace_new ();
+       replace = gtk_source_vim_command_new ("replace-one");
+       motion = gtk_source_vim_motion_new_forward_char ();
+       selection_motion = gtk_source_vim_motion_new_none ();
+       gtk_source_vim_state_set_count (motion, count);
+
+       gtk_source_vim_command_set_motion (GTK_SOURCE_VIM_COMMAND (replace),
+                                          GTK_SOURCE_VIM_MOTION (motion));
+       gtk_source_vim_command_set_selection_motion (GTK_SOURCE_VIM_COMMAND (replace),
+                                                    GTK_SOURCE_VIM_MOTION (selection_motion));
 
        gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), replace);
        gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (replace), char_pending);
 
+       g_object_unref (motion);
+       g_object_unref (selection_motion);
+
        return TRUE;
 }
 


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