From 73e2683f6aeda9bfdd3977f44f9179ead247b740 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 16 Oct 2026 12:01:33 +0000 Subject: [PATCH 1/2] Redraw the client after an OSC 11 background change, GitHub issue 5752 from Ilya Pozdnyakov. --- tty-keys.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tty-keys.c b/tty-keys.c index 67d38070e..7528bd340 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.219 2026/10/14 13:03:47 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.220 2026/10/16 12:01:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1785,8 +1785,12 @@ tty_keys_colours1(struct tty *tty, const char *buf, size_t len, size_t *size, n = tty_keys_colours(tty, buf, len, size, &tty->fg, &tty->bg); if (n == 0) { - if (tty->bg != bg) + if (tty->bg != bg) { server_client_update_theme_colours(c); + if (tty->flags & TTY_OPENED) + tty_invalidate(tty); + server_redraw_client(c); + } session_theme_changed(c->session); } return (n); From 6398970b2e5f2b9aa12773a29adae2dabb683ef7 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 16 Oct 2026 12:17:03 +0000 Subject: [PATCH 2/2] Check the column when looking up search marks in case the cursor is past the last column, GitHub issue 5756 from Alejandro Pacheco. --- window-copy.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/window-copy.c b/window-copy.c index 4949582ec..53012565e 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.438 2026/10/13 23:17:42 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.439 2026/10/16 12:17:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -87,6 +87,8 @@ static int window_copy_last_regex(struct grid *, u_int, u_int, u_int, int); static int window_copy_search_mark_at(struct window_copy_mode_data *, u_int, u_int, u_int *); +static int window_copy_search_mark_at_cursor( + struct window_copy_mode_data *, u_int *, int *); static int window_copy_grow_searchpos(struct window_copy_mode_data *, u_int, u_int, u_int); static void window_copy_search_set_index(struct window_copy_mode_data *, @@ -5109,6 +5111,8 @@ window_copy_search_mark_at(struct window_copy_mode_data *data, u_int px, struct screen *s = data->backing; struct grid *gd = s->grid; + if (px >= gd->sx) + return (-1); if (py < gd->hsize - data->oy) return (-1); if (py > gd->hsize - data->oy + gd->sy - 1) @@ -5117,6 +5121,23 @@ window_copy_search_mark_at(struct window_copy_mode_data *data, u_int px, return (0); } +/* + * Get the search mark position of the cursor. If the cursor is after the last + * column, use the last cell and set after. + */ +static int +window_copy_search_mark_at_cursor(struct window_copy_mode_data *data, + u_int *at, int *after) +{ + u_int cx = data->cx, cy, sx = screen_size_x(data->backing); + + cy = screen_hsize(data->backing) - data->oy + data->cy; + *after = (cx >= sx); + if (*after) + cx = sx - 1; + return (window_copy_search_mark_at(data, cx, cy, at)); +} + static u_int window_copy_clip_width(u_int width, u_int b, u_int sx, u_int sy) { @@ -5436,20 +5457,20 @@ window_copy_match_at_cursor(struct window_copy_mode_data *data) { struct grid *gd = data->backing->grid; struct grid_cell gc; - u_int at, start, end, cy, px, py; + u_int at, start, end, px, py; u_int sx = screen_size_x(data->backing); char *buf = NULL; size_t len = 0; + int after; if (data->searchmark == NULL) return (NULL); - cy = screen_hsize(data->backing) - data->oy + data->cy; - if (window_copy_search_mark_at(data, data->cx, cy, &at) != 0) + if (window_copy_search_mark_at_cursor(data, &at, &after) != 0) return (NULL); if (data->searchmark[at] == 0) { /* Allow one position after the match. */ - if (at == 0 || data->searchmark[--at] == 0) + if (after || at == 0 || data->searchmark[--at] == 0) return (NULL); } window_copy_match_start_end(data, at, &start, &end); @@ -5489,7 +5510,7 @@ window_copy_update_style(struct window_mode_entry *wme, u_int fx, u_int fy, struct window_pane *wp = wme->wp; struct window_copy_mode_data *data = wme->data; u_int mark, start, end, cy, cursor, current; - int inv = 0, found = 0; + int inv = 0, found = 0, after; int keys; cy = screen_hsize(data->backing) - data->oy + data->cy; @@ -5524,16 +5545,16 @@ window_copy_update_style(struct window_mode_entry *wme, u_int fx, u_int fy, if (mark == 0) return; - if (window_copy_search_mark_at(data, data->cx, cy, &cursor) == 0) { + if (window_copy_search_mark_at_cursor(data, &cursor, &after) == 0) { keys = options_get_number(wp->window->options, "mode-keys"); - if (cursor != 0 && + if ((after || cursor != 0) && keys == MODEKEY_EMACS && data->searchdirection) { - if (data->searchmark[cursor - 1] == mark) { + if (!after) cursor--; + if (data->searchmark[cursor] == mark) found = 1; - } - } else if (data->searchmark[cursor] == mark) + } else if (!after && data->searchmark[cursor] == mark) found = 1; if (found) { window_copy_match_start_end(data, cursor, &start, &end);