Do not bind global hooks to a session.

This commit is contained in:
Nicholas Marriott
2026-07-10 10:17:41 +01:00
parent a074224256
commit fd00ec6386
2 changed files with 16 additions and 1 deletions

View File

@@ -138,6 +138,7 @@ cmd_set_hook_monitor_exec(struct cmdq_item *item, struct args *args, int window)
struct cmd_find_state *target = cmdq_get_target(item), fs;
struct options *oo;
struct options_entry *o;
struct session *s = NULL;
char *cause = NULL, *name = NULL, *format = NULL;
char *expanded = NULL, *newvalue = NULL;
const char *value, *old;
@@ -199,7 +200,11 @@ cmd_set_hook_monitor_exec(struct cmdq_item *item, struct args *args, int window)
}
}
hooks_monitor_add(item, oo, name, type, id, format, &fs, target->s);
if (oo != global_options &&
oo != global_s_options &&
oo != global_w_options)
s = target->s;
hooks_monitor_add(item, oo, name, type, id, format, &fs, s);
out:
free(newvalue);

View File

@@ -147,4 +147,14 @@ $TMUX set -pt "$target_pane" @target-value changed ||
fail "set pane @target-value failed"
wait_for @target-pane "$target_pane"
$TMUX new -d -s zzz-survivor || fail "new survivor session failed"
$TMUX set -g @global-after-destroy 0 ||
fail "set @global-after-destroy failed"
$TMUX set-hook -g -t three -B '@global-after-destroy-session::#{session_name}' \
'set -g @global-after-destroy "#{hook_last}->#{hook_value}"' ||
fail "set-hook -B global after destroy failed"
assert_unchanged @global-after-destroy 0
$TMUX kill-session -t three || fail "kill destroyed monitor session failed"
wait_for @global-after-destroy 'three->zzz-survivor'
exit 0