[gtksourceview] Revert "vim: make registers shared between views"



commit 4a0d2d5aac72c7705c65c38d7930e66fb4e6858c
Author: Christian Hergert <chergert redhat com>
Date:   Thu May 19 21:29:13 2022 -0700

    Revert "vim: make registers shared between views"
    
    This reverts commit 83bd6880fc06775faa7131dd015fd83b0d5cb7c3.

 gtksourceview/vim/gtksourcevimstate.c       | 26 ++++++++++++++++++--------
 gtksourceview/vim/gtksourcevimstate.h       |  2 +-
 gtksourceview/vim/gtksourcevimtexthistory.c |  2 +-
 testsuite/test-vim-input.c                  |  3 ---
 4 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/gtksourceview/vim/gtksourcevimstate.c b/gtksourceview/vim/gtksourcevimstate.c
index 50b1e005..530e50c0 100644
--- a/gtksourceview/vim/gtksourcevimstate.c
+++ b/gtksourceview/vim/gtksourcevimstate.c
@@ -36,7 +36,8 @@
 
 typedef struct
 {
-       /* Owned reference to marks/etc (usually set low in the stack) */
+       /* Owned reference to marks/registers (usually set low in the stack) */
+       GtkSourceVimState *registers;
        GtkSourceVimState *marks;
        GtkSourceVimState *jumplist;
 
@@ -93,7 +94,6 @@ enum {
 };
 
 static GParamSpec *properties [N_PROPS];
-static GtkSourceVimState *shared_registers;
 
 void
 gtk_source_vim_state_keyval_unescaped (guint           keyval,
@@ -299,6 +299,7 @@ gtk_source_vim_state_dispose (GObject *object)
        g_clear_object (&priv->search_context);
        g_clear_object (&priv->search_settings);
 
+       gtk_source_vim_state_release (&priv->registers);
        gtk_source_vim_state_release (&priv->marks);
        gtk_source_vim_state_release (&priv->jumplist);
 
@@ -1084,14 +1085,23 @@ gtk_source_vim_state_set_can_repeat (GtkSourceVimState *self,
 }
 
 GtkSourceVimState *
-gtk_source_vim_state_get_registers (void)
+gtk_source_vim_state_get_registers (GtkSourceVimState *self)
 {
-       if (shared_registers == NULL)
+       GtkSourceVimStatePrivate *priv;
+       GtkSourceVimState *root;
+
+       g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
+
+       root = gtk_source_vim_state_get_root (self);
+       priv = gtk_source_vim_state_get_instance_private (root);
+
+       if (priv->registers == NULL)
        {
-               shared_registers = gtk_source_vim_registers_new ();
+               priv->registers = gtk_source_vim_registers_new ();
+               gtk_source_vim_state_set_parent (priv->registers, GTK_SOURCE_VIM_STATE (root));
        }
 
-       return shared_registers;
+       return priv->registers;
 }
 
 const char *
@@ -1137,7 +1147,7 @@ gtk_source_vim_state_get_current_register_value (GtkSourceVimState *self)
        g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), NULL);
 
        current_register = gtk_source_vim_state_get_current_register (self);
-       registers = gtk_source_vim_state_get_registers ();
+       registers = gtk_source_vim_state_get_registers (self);
 
        return gtk_source_vim_registers_get (GTK_SOURCE_VIM_REGISTERS (registers), current_register);
 }
@@ -1152,7 +1162,7 @@ gtk_source_vim_state_set_current_register_value (GtkSourceVimState *self,
        g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
 
        current_register = gtk_source_vim_state_get_current_register (self);
-       registers = gtk_source_vim_state_get_registers ();
+       registers = gtk_source_vim_state_get_registers (self);
 
        if (!gtk_source_vim_register_is_read_only (current_register))
        {
diff --git a/gtksourceview/vim/gtksourcevimstate.h b/gtksourceview/vim/gtksourcevimstate.h
index 190fabfc..6b12bde5 100644
--- a/gtksourceview/vim/gtksourcevimstate.h
+++ b/gtksourceview/vim/gtksourcevimstate.h
@@ -75,7 +75,7 @@ GtkSourceBuffer   *gtk_source_vim_state_get_buffer                 (GtkSourceVim
                                                                     GtkTextIter              
*selection_bound);
 GtkSourceVimState *gtk_source_vim_state_get_root                   (GtkSourceVimState        *self);
 GtkSourceVimState *gtk_source_vim_state_get_parent                 (GtkSourceVimState        *self);
-GtkSourceVimState *gtk_source_vim_state_get_registers              (void);
+GtkSourceVimState *gtk_source_vim_state_get_registers              (GtkSourceVimState        *self);
 int                gtk_source_vim_state_get_count                  (GtkSourceVimState        *self);
 gboolean           gtk_source_vim_state_get_count_set              (GtkSourceVimState        *self);
 void               gtk_source_vim_state_set_count                  (GtkSourceVimState        *self,
diff --git a/gtksourceview/vim/gtksourcevimtexthistory.c b/gtksourceview/vim/gtksourcevimtexthistory.c
index 5a50b23d..3a546f6c 100644
--- a/gtksourceview/vim/gtksourcevimtexthistory.c
+++ b/gtksourceview/vim/gtksourcevimtexthistory.c
@@ -287,7 +287,7 @@ gtk_source_vim_text_history_end (GtkSourceVimTextHistory *self)
                }
        }
 
-       registers = gtk_source_vim_state_get_registers ();
+       registers = gtk_source_vim_state_get_registers (GTK_SOURCE_VIM_STATE (self));
        gtk_source_vim_registers_set (GTK_SOURCE_VIM_REGISTERS (registers), ".", inserted->str);
        g_string_free (inserted, TRUE);
 }
diff --git a/testsuite/test-vim-input.c b/testsuite/test-vim-input.c
index 205080bc..05703ee3 100644
--- a/testsuite/test-vim-input.c
+++ b/testsuite/test-vim-input.c
@@ -26,7 +26,6 @@
 #include <gtksourceview/vim/gtksourcevimcommand.h>
 #include <gtksourceview/vim/gtksourceviminsert.h>
 #include <gtksourceview/vim/gtksourcevimnormal.h>
-#include <gtksourceview/vim/gtksourcevimregisters.h>
 #include <gtksourceview/vim/gtksourcevimstate.h>
 
 static void
@@ -42,8 +41,6 @@ run_test (const char *text,
        GtkTextIter begin, end;
        char *ret;
 
-       gtk_source_vim_registers_reset (GTK_SOURCE_VIM_REGISTERS (gtk_source_vim_state_get_registers ()));
-
        gtk_source_buffer_set_style_scheme (buffer, scheme);
 
        gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buffer), text, -1);


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