=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window-copy.c,v retrieving revision 1.261 retrieving revision 1.262 diff -u -r1.261 -r1.262 --- src/usr.bin/tmux/window-copy.c 2020/04/01 07:52:07 1.261 +++ src/usr.bin/tmux/window-copy.c 2020/04/01 08:07:05 1.262 @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.261 2020/04/01 07:52:07 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.262 2020/04/01 08:07:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2714,23 +2714,27 @@ struct screen *s = data->backing, ss; struct screen_write_ctx ctx; struct grid *gd = s->grid; + const char *str = data->searchstr; u_int fx, fy, endline; int wrapflag, cis, found; + if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0') + regex = 0; + free(wp->searchstr); - wp->searchstr = xstrdup(data->searchstr); + wp->searchstr = xstrdup(str); wp->searchregex = regex; fx = data->cx; fy = screen_hsize(data->backing) - data->oy + data->cy; - screen_init(&ss, screen_write_strlen("%s", data->searchstr), 1, 0); + screen_init(&ss, screen_write_strlen("%s", str), 1, 0); screen_write_start(&ctx, NULL, &ss); - screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr); + screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", str); screen_write_stop(&ctx); wrapflag = options_get_number(wp->window->options, "wrap-search"); - cis = window_copy_is_lowercase(data->searchstr); + cis = window_copy_is_lowercase(str); if (direction) { window_copy_move_right(s, &fx, &fy, wrapflag);