[gnome-builder/wip/vim] vim: make `b` preserve selection.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: make `b` preserve selection.
- Date: Tue, 30 Sep 2014 21:00:41 +0000 (UTC)
commit f19297808edfb6b12b273c0052c006a6872349cb
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 30 14:00:35 2014 -0700
vim: make `b` preserve selection.
src/editor/gb-editor-vim.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 3e66785..2787797 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -354,21 +354,30 @@ gb_editor_vim_move_backward_word (GbEditorVim *vim)
{
GtkTextBuffer *buffer;
GtkTextIter iter;
+ GtkTextIter selection;
GtkTextMark *insert;
+ gboolean has_selection;
g_assert (GB_IS_EDITOR_VIM (vim));
buffer = gtk_text_view_get_buffer (vim->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);
if (!gtk_text_iter_backward_word_start (&iter))
gtk_text_buffer_get_start_iter (buffer, &iter);
- gtk_text_buffer_select_range (buffer, &iter, &iter);
+ if (has_selection)
+ {
+ if (gtk_text_iter_equal (&iter, &selection))
+ gtk_text_iter_backward_word_start (&iter);
+ 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_scroll_mark_onscreen (vim->priv->text_view, insert);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]