[gnome-builder/wip/vim] vim: handle corner case with line selection at end of buffer.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: handle corner case with line selection at end of buffer.
- Date: Thu, 2 Oct 2014 20:51:07 +0000 (UTC)
commit 1dec5f9f08a02553c99a9c942ae4824fc07f01fd
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 2 13:50:55 2014 -0700
vim: handle corner case with line selection at end of buffer.
src/editor/gb-editor-vim.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index f28d59c..73d81fb 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -927,9 +927,17 @@ gb_editor_vim_move_down (GbEditorVim *vim)
*/
if (is_single_line_selection (&iter, &selection))
{
+ guint target_line;
+
if (gtk_text_iter_compare (&iter, &selection) < 0)
text_iter_swap (&iter, &selection);
- gtk_text_iter_set_line (&iter, gtk_text_iter_get_line (&iter) + 1);
+
+ target_line = gtk_text_iter_get_line (&iter) + 1;
+ gtk_text_iter_set_line (&iter, target_line);
+
+ if (target_line != gtk_text_iter_get_line (&iter))
+ goto select_to_end;
+
gb_editor_vim_select_range (vim, &iter, &selection);
gb_editor_vim_ensure_anchor_selected (vim);
goto move_mark;
@@ -956,6 +964,18 @@ gb_editor_vim_move_down (GbEditorVim *vim)
else
gtk_text_buffer_select_range (buffer, &iter, &iter);
}
+ else
+ {
+select_to_end:
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ if (has_selection)
+ {
+ gb_editor_vim_select_range (vim, &iter, &selection);
+ gb_editor_vim_ensure_anchor_selected (vim);
+ }
+ else
+ gtk_text_buffer_select_range (buffer, &iter, &iter);
+ }
move_mark:
insert = gtk_text_buffer_get_insert (buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]