[gtksourceview] vim: fix dd at end of buffer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] vim: fix dd at end of buffer
- Date: Tue, 23 Nov 2021 14:57:51 +0000 (UTC)
commit 820b558003f29071a987bf6a9fd41f78666f5df0
Author: Christian Hergert <chergert redhat com>
Date: Mon Nov 22 06:43:52 2021 -0800
vim: fix dd at end of buffer
This also fixes things like `dj` the line above the EOB.
gtksourceview/vim/gtksourcevimcommand.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/gtksourceview/vim/gtksourcevimcommand.c b/gtksourceview/vim/gtksourcevimcommand.c
index cca0a6f7..46b9bf65 100644
--- a/gtksourceview/vim/gtksourcevimcommand.c
+++ b/gtksourceview/vim/gtksourcevimcommand.c
@@ -211,6 +211,24 @@ gtk_source_vim_command_delete (GtkSourceVimCommand *self)
gtk_source_vim_state_set_current_register_value (GTK_SOURCE_VIM_STATE (self), text);
+ if (self->motion != NULL)
+ {
+ if (gtk_source_vim_motion_is_linewise (self->motion))
+ {
+ gtk_text_iter_order (&iter, &selection);
+
+ /* If we are at the end of the buffer, then we need
+ * to emulate linewise by swallowing the leading
+ * newline.
+ */
+ if (gtk_text_iter_is_end (&selection) &&
+ gtk_text_iter_starts_line (&iter))
+ {
+ gtk_text_iter_backward_char (&iter);
+ }
+ }
+ }
+
gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (buffer));
gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &iter, &selection);
gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (buffer));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]