From 466066c3a1393bb2c485b0cfc616b5d9e0afc5f9 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 6 Sep 2017 07:12:41 +0000 Subject: [PATCH 1/5] Do not attempt to use TIOCSWINSZ on a -1 file descriptor (possible if the pane has already died). --- server-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-client.c b/server-client.c index 2263deca..0b4146a8 100644 --- a/server-client.c +++ b/server-client.c @@ -1069,7 +1069,7 @@ server_client_resize_force(struct window_pane *wp) memset(&ws, 0, sizeof ws); ws.ws_col = wp->sx; ws.ws_row = wp->sy - 1; - if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) + if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) fatal("ioctl failed"); log_debug("%s: %%%u forcing resize", __func__, wp->id); @@ -1095,7 +1095,7 @@ server_client_resize_event(__unused int fd, __unused short events, void *data) memset(&ws, 0, sizeof ws); ws.ws_col = wp->sx; ws.ws_row = wp->sy; - if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) + if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) fatal("ioctl failed"); log_debug("%s: %%%u resize to %u,%u", __func__, wp->id, wp->sx, wp->sy); From 89e057dc4a8410207d3888e901eb3a3062002190 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 7 Sep 2017 13:18:44 +0000 Subject: [PATCH 2/5] Do not fail if unset an option that is already unset, reported by Thomas Sattler. --- cmd-set-option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-set-option.c b/cmd-set-option.c index 02504d5c..d1ec6fcf 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -190,7 +190,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item) /* Change the option. */ if (args_has(args, 'u')) { if (o == NULL) - goto fail; + goto out; if (idx == -1) { if (oo == global_options || oo == global_s_options || From 78cf3c14ca44bbbebd3fcb374c0397c72caf6c78 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 8 Sep 2017 08:45:27 +0000 Subject: [PATCH 3/5] When removing a key table clear it out of clients, fixes issue with unbind -a reported by Thomas Sattler. --- key-bindings.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/key-bindings.c b/key-bindings.c index 39083af0..badbc0f4 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -138,12 +138,17 @@ void key_bindings_remove_table(const char *name) { struct key_table *table; + struct client *c; table = key_bindings_get_table(name, 0); if (table != NULL) { RB_REMOVE(key_tables, &key_tables, table); key_bindings_unref_table(table); } + TAILQ_FOREACH(c, &clients, entry) { + if (c->keytable == table) + server_client_set_key_table(c, NULL); + } } void From f56f09ea3871d3099dd31030501b982a4243a372 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 8 Sep 2017 16:28:41 +0000 Subject: [PATCH 4/5] Fix a few errors in how the selected line is chosen after resize, reported by Felix Rosencrantz in GitHub issue 1059. --- mode-tree.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mode-tree.c b/mode-tree.c index fc31592a..ad783bb4 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -127,6 +127,17 @@ mode_tree_free_items(struct mode_tree_list *mtl) } } +static void +mode_tree_check_selected(struct mode_tree_data *mtd) +{ + /* + * If the current line would now be off screen reset the offset to the + * last visible line. + */ + if (mtd->current > mtd->height - 1) + mtd->offset = mtd->current - mtd->height + 1; +} + static void mode_tree_clear_lines(struct mode_tree_data *mtd) { @@ -192,7 +203,7 @@ mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) if (i != mtd->line_size) { mtd->current = i; if (mtd->current > mtd->height - 1) - mtd->offset = 1 + mtd->current - mtd->height; + mtd->offset = mtd->current - mtd->height + 1; else mtd->offset = 0; } else { @@ -361,6 +372,7 @@ mode_tree_build(struct mode_tree_data *mtd) mtd->height = screen_size_y(s); } else mtd->height = screen_size_y(s); + mode_tree_check_selected(mtd); } static void @@ -792,7 +804,7 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, case KEYC_END: mtd->current = mtd->line_size - 1; if (mtd->current > mtd->height - 1) - mtd->offset = mtd->current - mtd->height; + mtd->offset = mtd->current - mtd->height + 1; else mtd->offset = 0; break; @@ -870,15 +882,8 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, case 'v': mtd->preview = !mtd->preview; mode_tree_build(mtd); - - /* - * If the current line would now be off screen now the preview - * is on, reset the the offset to the last visible line. - */ - if (mtd->preview && mtd->current > mtd->height - 1) { - mtd->offset = mtd->current - mtd->height; - mtd->current--; - } + if (mtd->preview) + mode_tree_check_selected(mtd); break; } return (0); From 8405fcdd9b62e22003923a22edfefdaf42883a98 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 10 Sep 2017 08:01:23 +0000 Subject: [PATCH 5/5] Apply timeout to CAN and RS which also wait for ST. --- input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input.c b/input.c index b67d2362..e4aecf7d 100644 --- a/input.c +++ b/input.c @@ -433,7 +433,7 @@ static const struct input_state input_state_rename_string = { /* consume_st state definition. */ static const struct input_state input_state_consume_st = { "consume_st", - NULL, NULL, + input_enter_rename, NULL, /* rename also waits for ST */ input_state_consume_st_table };