From 2c0f826c360fc5a8f0e125759b596eb28441ba65 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 22 Apr 2017 08:56:24 +0000 Subject: Mouse bindings and hooks set up an initial current state when running a command. This is used for the session, window and pane for all commands in the command sequence if there is no -t or -s. However, using it for all commands in the command sequence means that if the active pane or current session is changed, subsequent commands still use the previous state. So make commands which explicitly change the current state (such as neww and selectp) update it themselves for later commands. Commands which may invalidate the state (like killp) are already OK because an invalid state will be ignored. Also fill in the current state for all key bindings rather than just the mouse, so that any omissions are easier to spot. --- cmd-join-pane.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmd-join-pane.c') diff --git a/cmd-join-pane.c b/cmd-join-pane.c index d2a50282..eb2f6022 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -63,6 +63,7 @@ static enum cmd_retval cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; + struct cmd_find_state *current = &item->shared->current; struct session *dst_s; struct winlink *src_wl, *dst_wl; struct window *src_w, *dst_w; @@ -146,6 +147,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) if (!args_has(args, 'd')) { window_set_active_pane(dst_w, src_wp); session_select(dst_s, dst_idx); + cmd_find_from_session(current, dst_s); server_redraw_session(dst_s); } else server_status_session(dst_s); -- cgit From ee45a8a149e1a3c8fe7c232a9e32f3a007e21bee Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 22 Apr 2017 10:22:39 +0000 Subject: Get rid of the extra layer of flags and cmd_prepare() and just store the CMD_FIND_* flags in the cmd_entry and call it for the command. Commands with special requirements call it themselves and update the target for hooks to use. --- cmd-join-pane.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'cmd-join-pane.c') diff --git a/cmd-join-pane.c b/cmd-join-pane.c index eb2f6022..a4ab81f7 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -38,8 +38,8 @@ const struct cmd_entry cmd_join_pane_entry = { .args = { "bdhvp:l:s:t:", 0, 0 }, .usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE, - .sflag = CMD_PANE_MARKED, - .tflag = CMD_PANE, + .source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED }, + .target = { 't', CMD_FIND_PANE, 0 }, .flags = 0, .exec = cmd_join_pane_exec @@ -52,8 +52,8 @@ const struct cmd_entry cmd_move_pane_entry = { .args = { "bdhvp:l:s:t:", 0, 0 }, .usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE, - .sflag = CMD_PANE, - .tflag = CMD_PANE, + .source = { 's', CMD_FIND_PANE, 0 }, + .target = { 't', CMD_FIND_PANE, 0 }, .flags = 0, .exec = cmd_join_pane_exec @@ -79,15 +79,15 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) else not_same_window = 0; - dst_s = item->state.tflag.s; - dst_wl = item->state.tflag.wl; - dst_wp = item->state.tflag.wp; + dst_s = item->target.s; + dst_wl = item->target.wl; + dst_wp = item->target.wp; dst_w = dst_wl->window; dst_idx = dst_wl->idx; server_unzoom_window(dst_w); - src_wl = item->state.sflag.wl; - src_wp = item->state.sflag.wp; + src_wl = item->source.wl; + src_wp = item->source.wp; src_w = src_wl->window; server_unzoom_window(src_w); -- cgit