[gtksourceview/wip/chergert/vim] fix the enter motion a bit more
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] fix the enter motion a bit more
- Date: Sun, 24 Oct 2021 16:46:55 +0000 (UTC)
commit 77997878a266beb64f37628939edb66142fe997a
Author: Christian Hergert <chergert redhat com>
Date: Sun Oct 24 09:46:50 2021 -0700
fix the enter motion a bit more
gtksourceview/vim/gtk-source-vim-motion.c | 47 ++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 17 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index 6e704876..130afbbc 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -467,32 +467,45 @@ motion_next_line (GtkTextIter *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_forward_to_line_end (iter))
+ gtk_text_iter_forward_char (iter);
+
+ if (gtk_text_iter_is_end (iter))
+ gtk_text_iter_backward_char (iter);
+
+ return !gtk_text_iter_equal (&before, iter);
+}
+
+static gboolean
+motion_next_line_first_char (GtkTextIter *iter,
+ GtkSourceVimMotion *state)
+{
+ GtkTextIter before = *iter;
+
+ if (!gtk_text_iter_ends_line (iter))
+ gtk_text_iter_forward_to_line_end (iter);
+
+ gtk_text_iter_forward_char (iter);
+ /* If we are on the same line, then we must be at the end of
+ * the buffer. Just move to one character before EOB.
+ */
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_equal (&before, iter);
}
- motion_line_first_char (iter, state);
-
- return !gtk_text_iter_equal (iter, &before);
-}
+ while (!gtk_text_iter_ends_line (iter) &&
+ g_unichar_isspace (gtk_text_iter_get_char (iter)))
+ {
+ if (!gtk_text_iter_forward_char (iter))
+ break;
+ }
-static gboolean
-motion_next_line_first_char (GtkTextIter *iter,
- GtkSourceVimMotion *state)
-{
- return motion_next_line (iter, state) &&
- motion_line_first_char (iter, state);
+ return !gtk_text_iter_equal (&before, iter);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]