[gnome-builder] vim: make move_line_start() act closer to VIM
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: make move_line_start() act closer to VIM
- Date: Thu, 16 Oct 2014 01:04:33 +0000 (UTC)
commit a4274c78e50babb30b44a7163e242412da1b4658
Author: Christian Hergert <christian hergert me>
Date: Wed Oct 15 18:04:20 2014 -0700
vim: make move_line_start() act closer to VIM
This uses the line content and context of command to determine if we
are allowed to go forwards when searching for the first non-whitespace
character. Ctrl+U cannot, but Shift+I can (for example).
src/editor/gb-editor-vim.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index daecdb9..8172ec7 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -694,7 +694,8 @@ gb_editor_vim_move_line0 (GbEditorVim *vim)
}
static void
-gb_editor_vim_move_line_start (GbEditorVim *vim)
+gb_editor_vim_move_line_start (GbEditorVim *vim,
+ gboolean can_move_forward)
{
GtkTextBuffer *buffer;
GtkTextIter iter;
@@ -721,11 +722,14 @@ gb_editor_vim_move_line_start (GbEditorVim *vim)
* If we failed to find a non-whitespace character or ended up at the
* same place we already were, just use the 0 index position.
*/
- if (g_unichar_isspace (gtk_text_iter_get_char (&iter)) ||
- gtk_text_iter_equal (&iter, &original))
+ if (!can_move_forward)
{
- gb_editor_vim_move_line0 (vim);
- return;
+ if (g_unichar_isspace (gtk_text_iter_get_char (&iter)) ||
+ gtk_text_iter_equal (&iter, &original))
+ {
+ gb_editor_vim_move_line0 (vim);
+ return;
+ }
}
if (has_selection)
@@ -1996,7 +2000,7 @@ gb_editor_vim_delete_to_line_start (GbEditorVim *vim)
*/
if (!gtk_text_iter_starts_line (&begin))
{
- gb_editor_vim_move_line_start (vim);
+ gb_editor_vim_move_line_start (vim, FALSE);
gtk_text_buffer_get_iter_at_mark (buffer, &begin, insert);
@@ -3770,7 +3774,7 @@ gb_editor_vim_cmd_backward_start (GbEditorVim *vim,
{
g_assert (GB_IS_EDITOR_VIM (vim));
- gb_editor_vim_move_line_start (vim);
+ gb_editor_vim_move_line_start (vim, FALSE);
}
static void
@@ -4069,7 +4073,7 @@ gb_editor_vim_cmd_insert_start (GbEditorVim *vim,
gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_INSERT);
gb_editor_vim_clear_selection (vim);
- gb_editor_vim_move_line_start (vim);
+ gb_editor_vim_move_line_start (vim, TRUE);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]