[gnome-builder] vim: Factor out apply_motion() method
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: Factor out apply_motion() method
- Date: Sun, 5 Oct 2014 21:22:13 +0000 (UTC)
commit d94c421615801f93082a00a1f08650dbbca52657
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Oct 4 17:58:50 2014 +0200
vim: Factor out apply_motion() method
This saves a couple of lines and fixes count being ignored in yank.
https://bugzilla.gnome.org/show_bug.cgi?id=737912
src/editor/gb-editor-vim.c | 37 +++++++++++++++++--------------------
1 files changed, 17 insertions(+), 20 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 5a37a44..a9c51d9 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -1190,6 +1190,21 @@ gb_editor_vim_select_char (GbEditorVim *vim)
}
static void
+gb_editor_vim_apply_motion (GbEditorVim *vim,
+ char motion,
+ guint count)
+{
+ GbEditorVimCommand *cmd;
+
+ cmd = g_hash_table_lookup (gCommands, GINT_TO_POINTER (motion));
+ if (!cmd || (cmd->type != GB_EDITOR_VIM_COMMAND_MOVEMENT))
+ return;
+
+ gb_editor_vim_select_char (vim);
+ cmd->func (vim, count, '\0');
+}
+
+static void
gb_editor_vim_undo (GbEditorVim *vim)
{
GtkSourceUndoManager *undo;
@@ -2850,16 +2865,7 @@ gb_editor_vim_cmd_delete (GbEditorVim *vim,
if (modifier == 'd')
gb_editor_vim_cmd_select_line (vim, count, '\0');
else
- {
- GbEditorVimCommand *cmd;
-
- cmd = g_hash_table_lookup (gCommands, GINT_TO_POINTER (modifier));
- if (!cmd || (cmd->type != GB_EDITOR_VIM_COMMAND_MOVEMENT))
- return;
-
- gb_editor_vim_select_char (vim);
- cmd->func (vim, count, '\0');
- }
+ gb_editor_vim_apply_motion (vim, modifier, count);
gb_editor_vim_delete_selection (vim);
}
@@ -3181,16 +3187,7 @@ gb_editor_vim_cmd_yank (GbEditorVim *vim,
if (modifier == 'y')
gb_editor_vim_cmd_select_line (vim, count, '\0');
else
- {
- GbEditorVimCommand *cmd;
-
- cmd = g_hash_table_lookup (gCommands, GINT_TO_POINTER (modifier));
- if (!cmd || (cmd->type != GB_EDITOR_VIM_COMMAND_MOVEMENT))
- return;
-
- gb_editor_vim_select_char (vim);
- cmd->func (vim, 1, '\0');
- }
+ gb_editor_vim_apply_motion (vim, modifier, count);
gb_editor_vim_yank (vim);
gb_editor_vim_clear_selection (vim);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]