[gtksourceview/wip/chergert/vim] use linewise for delete when applicable
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] use linewise for delete when applicable
- Date: Wed, 3 Nov 2021 17:46:54 +0000 (UTC)
commit 4374f0441c5f219ab9ef973a50524e3baee2cf9c
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 3 10:43:00 2021 -0700
use linewise for delete when applicable
gtksourceview/vim/gtk-source-vim-delete.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-delete.c b/gtksourceview/vim/gtk-source-vim-delete.c
index 7f2ba456..3ec6368d 100644
--- a/gtksourceview/vim/gtk-source-vim-delete.c
+++ b/gtksourceview/vim/gtk-source-vim-delete.c
@@ -148,21 +148,33 @@ gtk_source_vim_delete_repeat (GtkSourceVimState *state)
if (!gtk_source_vim_motion_apply (self->motion, &insert, TRUE))
break;
} while (--count > 0);
+
+ if (gtk_source_vim_motion_is_linewise (self->motion))
+ {
+ gtk_source_vim_state_select_linewise (GTK_SOURCE_VIM_STATE (self), &insert,
&selection);
+ }
}
- /* Copy the deleted text to the unnamed register */
text = gtk_text_iter_get_slice (&insert, &selection);
+
+ if (gtk_text_iter_is_end (&insert) || gtk_text_iter_is_end (&selection))
+ {
+ char *tmp = text;
+ text = g_strdup_printf ("%s\n", tmp);
+ g_free (tmp);
+ }
+
gtk_source_vim_state_set_current_register_value (state, text);
- g_free (text);
gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &insert, &selection);
- if (gtk_text_iter_ends_line (&insert) &&
- !gtk_text_iter_starts_line (&insert))
+ if (gtk_text_iter_ends_line (&insert) && !gtk_text_iter_starts_line (&insert))
{
gtk_text_iter_backward_char (&insert);
gtk_source_vim_state_select (state, &insert, &insert);
}
+
+ g_free (text);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]