[gtksourceview/wip/chergert/vim] move insert back one character when leaving insert mode
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] move insert back one character when leaving insert mode
- Date: Fri, 22 Oct 2021 16:19:28 +0000 (UTC)
commit 050402b16c3c0c89ac8c3f7257cead9ee470a182
Author: Christian Hergert <chergert redhat com>
Date: Fri Oct 22 09:19:23 2021 -0700
move insert back one character when leaving insert mode
gtksourceview/vim/gtk-source-vim-insert.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-insert.c b/gtksourceview/vim/gtk-source-vim-insert.c
index d0877b4c..6b83748f 100644
--- a/gtksourceview/vim/gtk-source-vim-insert.c
+++ b/gtksourceview/vim/gtk-source-vim-insert.c
@@ -174,6 +174,24 @@ gtk_source_vim_insert_handle_event (GtkSourceVimState *state,
return FALSE;
}
+static void
+gtk_source_vim_insert_leave (GtkSourceVimState *state)
+{
+ GtkSourceBuffer *buffer;
+ GtkTextIter insert;
+
+ g_assert (GTK_SOURCE_IS_VIM_INSERT (state));
+
+ buffer = gtk_source_vim_state_get_buffer (state, &insert, NULL);
+
+ /* Move the cursor back one character */
+ if (!gtk_text_iter_starts_line (&insert) &&
+ gtk_text_iter_backward_char (&insert))
+ {
+ gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &insert, &insert);
+ }
+}
+
static void
gtk_source_vim_insert_dispose (GObject *object)
{
@@ -189,6 +207,7 @@ gtk_source_vim_insert_class_init (GtkSourceVimInsertClass *klass)
object_class->dispose = gtk_source_vim_insert_dispose;
state_class->handle_event = gtk_source_vim_insert_handle_event;
+ state_class->leave = gtk_source_vim_insert_leave;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]