[gtksourceview/wip/chergert/vim: 332/363] try harder to release vim states early
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 332/363] try harder to release vim states early
- Date: Mon, 8 Nov 2021 19:53:55 +0000 (UTC)
commit cde05ce40119e70e2714a886078075ff7dd7ba6e
Author: Christian Hergert <chergert redhat com>
Date: Sat Nov 6 10:02:50 2021 -0700
try harder to release vim states early
gtksourceview/vim/gtk-source-vim-command.c | 5 +++--
gtksourceview/vim/gtk-source-vim-insert.c | 6 +++++-
gtksourceview/vim/gtk-source-vim-motion.c | 4 ++++
gtksourceview/vim/gtk-source-vim-normal.c | 16 +++++++++++-----
gtksourceview/vim/gtk-source-vim-replace.c | 1 +
gtksourceview/vim/gtk-source-vim-state.c | 11 +++++++++++
gtksourceview/vim/gtk-source-vim-visual.c | 8 +++++---
7 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index 16b530f5..c8b366fb 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -717,13 +717,14 @@ gtk_source_vim_command_resume (GtkSourceVimState *state,
const char *string = gtk_source_vim_char_pending_get_string (GTK_SOURCE_VIM_CHAR_PENDING
(from));
if (ch && string && string[0])
- {
g_strlcpy (self->char_pending, string, sizeof self->char_pending);
- }
+ gtk_source_vim_state_unparent (from);
gtk_source_vim_state_pop (state);
return;
}
+
+ gtk_source_vim_state_unparent (from);
}
static int
diff --git a/gtksourceview/vim/gtk-source-vim-insert.c b/gtksourceview/vim/gtk-source-vim-insert.c
index 246910bd..15ec7320 100644
--- a/gtksourceview/vim/gtk-source-vim-insert.c
+++ b/gtksourceview/vim/gtk-source-vim-insert.c
@@ -181,16 +181,20 @@ gtk_source_vim_insert_resume (GtkSourceVimState *state,
g_assert (GTK_SOURCE_IS_VIM_INSERT (state));
g_assert (GTK_SOURCE_IS_VIM_STATE (from));
+ gtk_source_vim_state_set_overwrite (state, FALSE);
+
if (GTK_SOURCE_IS_VIM_REPLACE (from))
{
/* If we are leaving replace mode back to insert then
* we need also exit insert mode so we end up back on
* Normal mode.
*/
+ gtk_source_vim_state_unparent (from);
gtk_source_vim_state_pop (state);
+ return;
}
- gtk_source_vim_state_set_overwrite (state, FALSE);
+ gtk_source_vim_state_unparent (from);
}
static void
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index e33fcc6e..578000f8 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -1602,8 +1602,12 @@ gtk_source_vim_motion_resume (GtkSourceVimState *state,
self->f_char = ch;
g_string_append (self->command_text, str);
+ gtk_source_vim_state_unparent (from);
gtk_source_vim_state_pop (state);
+ return;
}
+
+ gtk_source_vim_state_unparent (from);
}
static void
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 0554ee1c..9a9fc121 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -1264,6 +1264,7 @@ gtk_source_vim_normal_resume (GtkSourceVimState *state,
GtkSourceBuffer *buffer;
GtkSourceView *view;
GtkTextMark *insert;
+ gboolean unparent = TRUE;
g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
g_assert (GTK_SOURCE_IS_VIM_STATE (from));
@@ -1281,15 +1282,14 @@ gtk_source_vim_normal_resume (GtkSourceVimState *state,
{
go_backward_char (self);
}
-
- if (GTK_SOURCE_IS_VIM_VISUAL (from))
+ else if (GTK_SOURCE_IS_VIM_VISUAL (from))
{
/* Store last visual around for reselection in gv */
gtk_source_vim_state_reparent (from, self, &self->last_visual);
+ unparent = FALSE;
}
-
- if (!GTK_SOURCE_IS_VIM_MOTION (from) ||
- gtk_source_vim_motion_invalidates_visual_column (GTK_SOURCE_VIM_MOTION (from)))
+ else if (!GTK_SOURCE_IS_VIM_MOTION (from) ||
+ gtk_source_vim_motion_invalidates_visual_column (GTK_SOURCE_VIM_MOTION (from)))
{
GtkTextIter iter;
guint visual_column;
@@ -1308,6 +1308,12 @@ gtk_source_vim_normal_resume (GtkSourceVimState *state,
if (gtk_source_vim_state_get_can_repeat (from))
{
gtk_source_vim_state_reparent (from, self, &self->repeat);
+ unparent = FALSE;
+ }
+
+ if (unparent)
+ {
+ gtk_source_vim_state_unparent (from);
}
}
diff --git a/gtksourceview/vim/gtk-source-vim-replace.c b/gtksourceview/vim/gtk-source-vim-replace.c
index b1a2a6b4..0ad1be4b 100644
--- a/gtksourceview/vim/gtk-source-vim-replace.c
+++ b/gtksourceview/vim/gtk-source-vim-replace.c
@@ -109,6 +109,7 @@ gtk_source_vim_replace_resume (GtkSourceVimState *state,
gtk_source_vim_state_set_overwrite (state, TRUE);
gtk_source_vim_state_end_user_action (state);
+ gtk_source_vim_state_unparent (from);
}
static void
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index 4d4d4103..d2bd25b0 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -256,6 +256,16 @@ gtk_source_vim_state_real_handle_event (GtkSourceVimState *self,
return FALSE;
}
+static void
+gtk_source_vim_state_real_resume (GtkSourceVimState *self,
+ GtkSourceVimState *from)
+{
+ g_assert (GTK_SOURCE_IS_VIM_STATE (self));
+ g_assert (GTK_SOURCE_IS_VIM_STATE (from));
+
+ gtk_source_vim_state_unparent (from);
+}
+
static void
gtk_source_vim_state_dispose (GObject *object)
{
@@ -352,6 +362,7 @@ gtk_source_vim_state_class_init (GtkSourceVimStateClass *klass)
object_class->set_property = gtk_source_vim_state_set_property;
klass->handle_event = gtk_source_vim_state_real_handle_event;
+ klass->resume = gtk_source_vim_state_real_resume;
properties [PROP_PARENT] =
g_param_spec_object ("parent",
diff --git a/gtksourceview/vim/gtk-source-vim-visual.c b/gtksourceview/vim/gtk-source-vim-visual.c
index 4908085b..29128479 100644
--- a/gtksourceview/vim/gtk-source-vim-visual.c
+++ b/gtksourceview/vim/gtk-source-vim-visual.c
@@ -709,12 +709,14 @@ gtk_source_vim_visual_resume (GtkSourceVimState *state,
update_cursor_visible (self);
- if (GTK_SOURCE_IS_VIM_INSERT (from) ||
- GTK_SOURCE_IS_VIM_REPLACE (from) ||
- GTK_SOURCE_IS_VIM_COMMAND (from))
+ if (from == self->command)
{
gtk_source_vim_state_pop (state);
}
+ else if (!GTK_SOURCE_IS_VIM_MOTION (from))
+ {
+ gtk_source_vim_state_unparent (from);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]