From bdab5950955539ea4ffab0816faf182607db4c2b Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 24 Jun 2019 08:20:02 +0000 Subject: [PATCH] Trim trailing spaces when matching. --- window.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/window.c b/window.c index 77ca2ce2..f900a1b2 100644 --- a/window.c +++ b/window.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -1222,6 +1223,7 @@ window_pane_search(struct window_pane *wp, const char *term, int regex, char *new = NULL, *line; u_int i; int flags = 0, found; + size_t n; if (!regex) { if (ignore) @@ -1236,6 +1238,12 @@ window_pane_search(struct window_pane *wp, const char *term, int regex, for (i = 0; i < screen_size_y(s); i++) { line = grid_view_string_cells(s->grid, 0, i, screen_size_x(s)); + for (n = strlen(line); n > 0; n--) { + if (!isspace((u_char)line[n - 1])) + break; + line[n - 1] = '\0'; + } + log_debug("%s: %s", __func__, line); if (!regex) found = (fnmatch(new, line, 0) == 0); else