From 0f6227f46b1d33476ef448682a2ba0b0290e6d9b Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 2 Jun 2022 20:41:21 +0000 Subject: [PATCH 1/2] When deleting or renaming a buffer and a buffer name is specified, complain if the buffer doesn't exist instead of silently deleting or renaming the most recent buffer. GitHub issue 3205. --- cmd-set-buffer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c index 9112683f..c9ffe5ed 100644 --- a/cmd-set-buffer.c +++ b/cmd-set-buffer.c @@ -69,8 +69,13 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item) pb = paste_get_name(bufname); if (cmd_get_entry(self) == &cmd_delete_buffer_entry) { - if (pb == NULL) + if (pb == NULL) { + if (bufname != NULL) { + cmdq_error(item, "unknown buffer: %s", bufname); + return (CMD_RETURN_ERROR); + } pb = paste_get_top(&bufname); + } if (pb == NULL) { cmdq_error(item, "no buffer"); return (CMD_RETURN_ERROR); @@ -80,8 +85,13 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'n')) { - if (pb == NULL) + if (pb == NULL) { + if (bufname != NULL) { + cmdq_error(item, "unknown buffer: %s", bufname); + return (CMD_RETURN_ERROR); + } pb = paste_get_top(&bufname); + } if (pb == NULL) { cmdq_error(item, "no buffer"); return (CMD_RETURN_ERROR); From 18838fbc877b5c003449fa10df353405c024f0f5 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 2 Jun 2022 21:19:32 +0000 Subject: [PATCH 2/2] Do not attempt to use client in config file (it will be NULL), GitHub issue 3206. --- cmd-run-shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-run-shell.c b/cmd-run-shell.c index db5774d2..560eface 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -84,7 +84,7 @@ cmd_run_shell_print(struct job *job, const char *msg) if (cdata->wp_id != -1) wp = window_pane_find_by_id(cdata->wp_id); - if (wp == NULL && cdata->item != NULL) + if (wp == NULL && cdata->item != NULL && cdata->client != NULL) wp = server_client_get_pane(cdata->client); if (wp == NULL && cmd_find_from_nothing(&fs, 0) == 0) wp = fs.wp;