[gnome-builder/wip/vim] vim: x should never cause non-current lines to change.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: x should never cause non-current lines to change.
- Date: Mon, 29 Sep 2014 22:43:55 +0000 (UTC)
commit 9ee8e397ee31004cb824edf2a1c7f64a99274c68
Author: Christian Hergert <christian hergert me>
Date: Mon Sep 29 15:42:43 2014 -0700
vim: x should never cause non-current lines to change.
This will no longer start deleting the next line or the previous line.
It will work forward or backwards on the current line only.
src/editor/gb-editor-vim.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 35ecd7d..c7e1cf3 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -350,9 +350,26 @@ gb_editor_vim_delete_selection (GbEditorVim *vim)
buffer = gtk_text_view_get_buffer (vim->priv->text_view);
gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
+ /*
+ * If there is no selection to delete, try to remove the next character
+ * in the line. If there is no next character, delete the last character
+ * in the line.
+ */
if (gtk_text_iter_equal (&begin, &end))
- if (!gtk_text_iter_forward_char (&end))
- return;
+ {
+ if (!gtk_text_iter_ends_line (&end))
+ {
+ if (!gtk_text_iter_forward_char (&end))
+ return;
+ }
+ else if (!gtk_text_iter_starts_line (&begin))
+ {
+ if (!gtk_text_iter_backward_char (&begin))
+ return;
+ }
+ else
+ return;
+ }
gtk_text_buffer_begin_user_action (buffer);
gtk_text_buffer_delete (buffer, &begin, &end);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]