[geany/geany-plugins] ef848d: Merge pull request #1104 from techee/vim_selection_char_problem

Frank Lanitz git-noreply at xxxxx
Wed Sep 29 17:10:45 UTC 2021


Branch:      refs/heads/master
Author:      Frank Lanitz <frank at frank.uvena.de>
Committer:   GitHub <noreply at github.com>
Date:        Wed, 29 Sep 2021 17:10:45 UTC
Commit:      ef848d838858ce0150e86481d46bc75b3dd390a7
             https://github.com/geany/geany-plugins/commit/ef848d838858ce0150e86481d46bc75b3dd390a7

Log Message:
-----------
Merge pull request #1104 from techee/vim_selection_char_problem

vimode: Add special handling to include destination char for some commands


Modified Paths:
--------------
    vimode/src/cmd-runner.c

Modified: vimode/src/cmd-runner.c
24 lines changed, 23 insertions(+), 1 deletions(-)
===================================================================
@@ -167,6 +167,21 @@ typedef struct {
 	/* END */
 
 
+/* From the above commands, these commands also include the character
+ * where the destionation movement ends for motion commands (e.g. 'de' will
+ * delete the word including the last character) */
+CmdDef include_dest_char_movement_cmds[] = {
+	{cmd_goto_next_char, GDK_KEY_f, 0, 0, 0, TRUE, FALSE},
+	{cmd_goto_next_char_before, GDK_KEY_t, 0, 0, 0, TRUE, FALSE},
+	{cmd_goto_next_word_end, GDK_KEY_e, 0, 0, 0, FALSE, FALSE},
+	{cmd_goto_next_word_end_space, GDK_KEY_E, 0, 0, 0, FALSE, FALSE},
+	{cmd_goto_previous_word, GDK_KEY_b, 0, 0, 0, FALSE, FALSE},
+	{cmd_goto_previous_word_space, GDK_KEY_B, 0, 0, 0, FALSE, FALSE},
+	{cmd_goto_matching_brace, GDK_KEY_percent, 0, 0, 0, FALSE, FALSE},
+	{NULL, 0, 0, 0, 0, FALSE, FALSE}
+};
+
+
 CmdDef movement_cmds[] = {
 	MOVEMENT_CMDS
 	{NULL, 0, 0, 0, 0, FALSE, FALSE}
@@ -567,7 +582,8 @@ static void perform_cmd(CmdDef *def, CmdContext *ctx)
 	if (VI_IS_COMMAND(vi_get_mode()))
 	{
 		gboolean is_text_object_cmd = is_in_cmd_group(text_object_cmds, def);
-		if (is_text_object_cmd ||is_in_cmd_group(movement_cmds, def))
+		gboolean is_include_dest_char_movement_cmd = is_in_cmd_group(include_dest_char_movement_cmds, def);
+		if (is_text_object_cmd || is_in_cmd_group(movement_cmds, def))
 		{
 			def = get_cmd_to_run(top, operator_cmds, TRUE);
 			if (def)
@@ -585,6 +601,12 @@ static void perform_cmd(CmdDef *def, CmdContext *ctx)
 				{
 					sel_start = MIN(new_pos, orig_pos);
 					sel_len = ABS(new_pos - orig_pos);
+					if (sel_len > 0 && is_include_dest_char_movement_cmd)
+					{
+						sel_len++;
+						if (new_pos < orig_pos)
+							sel_start--;
+					}
 				}
 				cmd_params_init(&param, ctx->sci,
 					1, FALSE, top, TRUE,



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list