From da650dc0cab3ddf3769f3d2fd8e265ba25ae095d Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 21 Aug 2021 14:06:17 +0000 Subject: [PATCH] Preserve command group when moving temporary list to current list being buit. --- usr.bin/tmux/cmd-parse.y | 4 ++-- usr.bin/tmux/cmd.c | 15 +++++++++++++-- usr.bin/tmux/tmux.h | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y index 35829b47d9a..14e39e80ae6 100644 --- a/usr.bin/tmux/cmd-parse.y +++ b/usr.bin/tmux/cmd-parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-parse.y,v 1.37 2021/08/20 20:08:30 nicm Exp $ */ +/* $OpenBSD: cmd-parse.y,v 1.38 2021/08/21 14:06:17 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -871,7 +871,7 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds, cmd_list_free(current); return; } - cmd_list_move(current, add); + cmd_list_append_all(current, add); cmd_list_free(add); } if (current != NULL) { diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index c255c162386..ed05e466427 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.167 2021/08/21 08:44:59 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.168 2021/08/21 14:06:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -594,7 +594,18 @@ cmd_list_append(struct cmd_list *cmdlist, struct cmd *cmd) TAILQ_INSERT_TAIL(cmdlist->list, cmd, qentry); } -/* Move all commands from one command list to another */ +/* Append all commands from one list to another. */ +void +cmd_list_append_all(struct cmd_list *cmdlist, struct cmd_list *from) +{ + struct cmd *cmd; + + TAILQ_FOREACH(cmd, from->list, qentry) + cmd->group = cmdlist->group; + TAILQ_CONCAT(cmdlist->list, from->list, qentry); +} + +/* Move all commands from one command list to another. */ void cmd_list_move(struct cmd_list *cmdlist, struct cmd_list *from) { diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 5a937ad6bd5..e4dabcb92e2 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1130 2021/08/21 10:28:05 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1131 2021/08/21 14:06:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2256,6 +2256,7 @@ void cmd_free(struct cmd *); char *cmd_print(struct cmd *); struct cmd_list *cmd_list_new(void); void cmd_list_append(struct cmd_list *, struct cmd *); +void cmd_list_append_all(struct cmd_list *, struct cmd_list *); void cmd_list_move(struct cmd_list *, struct cmd_list *); void cmd_list_free(struct cmd_list *); char *cmd_list_print(struct cmd_list *, int); -- 2.20.1