[gnome-builder/wip/vim] vim: try to handle selection properly in `vk' sequence.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: try to handle selection properly in `vk' sequence.
- Date: Thu, 2 Oct 2014 07:43:48 +0000 (UTC)
commit 6a5fe00413f40b2cc1e8110290e001b01dbcc7f1
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 2 00:43:42 2014 -0700
vim: try to handle selection properly in `vk' sequence.
src/editor/gb-editor-vim.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 172116c..18f6be4 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -691,6 +691,26 @@ is_single_line_selection (const GtkTextIter *begin,
gtk_text_iter_get_line (begin)));
}
+static gboolean
+is_single_char_selection (const GtkTextIter *begin,
+ const GtkTextIter *end)
+{
+ GtkTextIter tmp;
+
+ g_assert (begin);
+ g_assert (end);
+
+ gtk_text_iter_assign (&tmp, begin);
+ if (gtk_text_iter_forward_char (&tmp) && gtk_text_iter_equal (&tmp, end))
+ return TRUE;
+
+ gtk_text_iter_assign (&tmp, end);
+ if (gtk_text_iter_forward_char (&tmp) && gtk_text_iter_equal (&tmp, begin))
+ return TRUE;
+
+ return FALSE;
+}
+
static void
text_iter_swap (GtkTextIter *a,
GtkTextIter *b)
@@ -797,6 +817,13 @@ gb_editor_vim_move_up (GbEditorVim *vim)
GOTO (move_mark);
}
+ if (is_single_char_selection (&iter, &selection) &&
+ (gtk_text_iter_compare (&iter, &selection) > 0))
+ {
+ text_iter_swap (&iter, &selection);
+ gb_editor_vim_select_range (vim, &iter, &selection);
+ }
+
gtk_text_buffer_get_iter_at_line (buffer, &iter, line - 1);
if ((line - 1) == gtk_text_iter_get_line (&iter))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]