[gtksourceview/wip/chergert/vim] improve line motion a bit
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] improve line motion a bit
- Date: Sun, 24 Oct 2021 16:35:53 +0000 (UTC)
commit 0c01a17312830fed6adf8d652658adbb2221c672
Author: Christian Hergert <chergert redhat com>
Date: Sun Oct 24 09:35:47 2021 -0700
improve line motion a bit
gtksourceview/vim/gtk-source-vim-motion.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index d7f60618..6e704876 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -465,12 +465,26 @@ static gboolean
motion_next_line (GtkTextIter *iter,
GtkSourceVimMotion *state)
{
- if (!gtk_text_iter_ends_line (iter))
+ GtkTextIter before = *iter;
+
+ gtk_text_buffer_get_iter_at_line (gtk_text_iter_get_buffer (iter),
+ iter,
+ gtk_text_iter_get_line (iter) + 1);
+
+ if (gtk_text_iter_get_line (&before) == gtk_text_iter_get_line (iter))
{
+ /* must be at end of file now. move to end of buffer
+ * but do not go past the last character.
+ */
gtk_text_iter_forward_to_line_end (iter);
+ if (!gtk_text_iter_starts_line (iter))
+ gtk_text_iter_backward_char (iter);
+ return gtk_text_iter_equal (iter, &before);
}
- return gtk_text_iter_forward_char (iter);
+ motion_line_first_char (iter, state);
+
+ return !gtk_text_iter_equal (iter, &before);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]