[gnome-builder/wip/vim] vim: make `$` command respect selections.



commit 4ea09e33e3cbd252f1cf4e22b10f0f62bade6a9e
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 30 15:47:18 2014 -0700

    vim: make `$` command respect selections.

 src/editor/gb-editor-vim.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index a55c318..d68ac32 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -297,22 +297,29 @@ gb_editor_vim_move_line_end (GbEditorVim *vim)
   GtkTextBuffer *buffer;
   GtkTextMark *insert;
   GtkTextIter iter;
+  GtkTextIter selection;
+  gboolean has_selection;
 
   g_assert (GB_IS_EDITOR_VIM (vim));
 
   priv = vim->priv;
 
   buffer = gtk_text_view_get_buffer (priv->text_view);
-  insert = gtk_text_buffer_get_insert (buffer);
-  gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+  has_selection = gb_editor_vim_get_selection_bounds (vim, &iter, &selection);
 
   while (!gtk_text_iter_ends_line (&iter))
     if (!gtk_text_iter_forward_char (&iter))
       break;
 
-  gtk_text_buffer_select_range (buffer, &iter, &iter);
+  if (has_selection)
+    gb_editor_vim_select_range (vim, &iter, &selection);
+  else
+    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_move_mark_onscreen (vim->priv->text_view, insert);
 }
 
 static void


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