[gnome-builder/wip/vim] vim: clear selection upon redo of operation.



commit 20479c947336462409ac8d13d52a8c57a86f0a62
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 30 15:52:50 2014 -0700

    vim: clear selection upon redo of operation.

 src/editor/gb-editor-vim.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 3e56017..2585342 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -768,6 +768,7 @@ gb_editor_vim_redo (GbEditorVim *vim)
   GtkSourceUndoManager *undo;
   GtkTextBuffer *buffer;
   GtkTextMark *insert;
+  GtkTextIter iter;
 
   g_assert (GB_IS_EDITOR_VIM (vim));
 
@@ -782,9 +783,16 @@ gb_editor_vim_redo (GbEditorVim *vim)
   if (gtk_source_undo_manager_can_redo (undo))
     gtk_source_undo_manager_redo (undo);
 
+  /*
+   * GtkSourceView might preserve the selection. So let's go ahead and
+   * clear it manually to the insert mark position.
+   */
+  insert = gtk_text_buffer_get_insert (buffer);
+  gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+  gtk_text_buffer_select_range (buffer, &iter, &iter);
+
   vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
 
-  insert = gtk_text_buffer_get_insert (buffer);
   gtk_text_view_scroll_mark_onscreen (vim->priv->text_view, insert);
 }
 


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