[gtksourceview/wip/chergert/vim: 197/293] try harder to keep character from moving past end of line
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 197/293] try harder to keep character from moving past end of line
- Date: Fri, 5 Nov 2021 04:23:04 +0000 (UTC)
commit 33a79834de0abfce7d8ebd2cf94db49436c08804
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 1 17:13:24 2021 -0700
try harder to keep character from moving past end of line
gtksourceview/vim/gtk-source-vim-normal.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index db584ae4..56d4f74c 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -262,6 +262,19 @@ go_backward_char (GtkSourceVimNormal *self)
gtk_source_vim_state_select (GTK_SOURCE_VIM_STATE (self), &iter, &iter);
}
+static void
+keep_on_char (GtkSourceVimNormal *self)
+{
+ GtkTextIter iter;
+
+ gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), &iter, NULL);
+
+ if (gtk_text_iter_ends_line (&iter) && !gtk_text_iter_starts_line (&iter))
+ {
+ go_backward_char (self);
+ }
+}
+
static gboolean
key_handler_count (GtkSourceVimNormal *self,
guint keyval,
@@ -426,6 +439,7 @@ key_handler_command (GtkSourceVimNormal *self,
if (self->repeat != NULL)
{
gtk_source_vim_state_repeat (self->repeat);
+ keep_on_char (self);
return TRUE;
}
break;
@@ -1011,6 +1025,9 @@ gtk_source_vim_normal_resume (GtkSourceVimState *state,
g_set_object (&self->last_visual, from);
}
+ /* If we're still on the \n, go back a char */
+ keep_on_char (self);
+
/* Always scroll the insert mark onscreen */
gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW (view), insert);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]