[gnome-builder/wip/vim] vim: move clearing of snippets outside of GbEditorVim.



commit 51277fb92df3d868a2f0746ab9df196f7d8d42ab
Author: Christian Hergert <christian hergert me>
Date:   Thu Oct 2 04:24:17 2014 -0700

    vim: move clearing of snippets outside of GbEditorVim.

 src/editor/gb-editor-tab.c |   20 ++++++++++++++++++++
 src/editor/gb-editor-vim.c |    8 --------
 2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index ebbb7c1..7b11966 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -1041,6 +1041,22 @@ on_vim_notify_phrase (GbEditorVim *vim,
   gb_editor_tab_cursor_moved (tab, tab->priv->document);
 }
 
+static void
+on_vim_notify_mode (GbEditorVim *vim,
+                    GParamSpec  *pspec,
+                    GbEditorTab *tab)
+{
+  GbEditorVimMode mode;
+
+  g_return_if_fail (GB_IS_EDITOR_VIM (vim));
+  g_return_if_fail (GB_IS_EDITOR_TAB (tab));
+
+  mode = gb_editor_vim_get_mode (vim);
+
+  if (mode != GB_EDITOR_VIM_INSERT)
+    gb_source_view_clear_snippets (tab->priv->source_view);
+}
+
 static gboolean
 on_vim_command_entry_key_press_event (GtkEntry    *entry,
                                       GdkEventKey *event,
@@ -1258,6 +1274,10 @@ gb_editor_tab_constructed (GObject *object)
                     "notify::phrase",
                     G_CALLBACK (on_vim_notify_phrase),
                     tab);
+  g_signal_connect (priv->vim,
+                    "notify::mode",
+                    G_CALLBACK (on_vim_notify_mode),
+                    tab);
 
   g_signal_connect (priv->vim_command_entry,
                     "activate",
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index a21cb57..87f5976 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -20,7 +20,6 @@
 
 #include <errno.h>
 #include <glib/gi18n.h>
-#include <gtksourceview/gtksource.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -422,13 +421,6 @@ gb_editor_vim_set_mode (GbEditorVim     *vim,
     vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
 
   /*
-   * If there are any snippets active, escape out of them.
-   */
-  if ((mode != GB_EDITOR_VIM_INSERT) &&
-      GB_IS_SOURCE_VIEW (vim->priv->text_view))
-    gb_source_view_clear_snippets (GB_SOURCE_VIEW (vim->priv->text_view));
-
-  /*
    * Clear the current selection too.
    */
   gb_editor_vim_clear_selection (vim);


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