Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion vimode/src/cmd-runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down