summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-find-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2023-12-27 20:42:02 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2023-12-27 20:42:02 +0000
commit382efbd517c60d96ed7f7d2603bcb56e953f7791 (patch)
treea8191ac19ed92f9fca2bb8ca9015a3ca6260ff86 /usr.bin/tmux/cmd-find-window.c
parent2e8ced9c6b9b5e09ca0716bc88d1c579c79be3c0 (diff)
Only wrap pattern in *s if using a regular expression.
Diffstat (limited to 'usr.bin/tmux/cmd-find-window.c')
-rw-r--r--usr.bin/tmux/cmd-find-window.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c
index 5b7db89bc6a..28a8949cdd2 100644
--- a/usr.bin/tmux/cmd-find-window.c
+++ b/usr.bin/tmux/cmd-find-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find-window.c,v 1.55 2022/12/16 08:13:40 nicm Exp $ */
+/* $OpenBSD: cmd-find-window.c,v 1.56 2023/12/27 20:42:01 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -48,6 +48,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp;
const char *s = args_string(args, 0), *suffix = "";
+ const char *star = "*";
struct args_value *filter;
int C, N, T;
@@ -55,6 +56,8 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
N = args_has(args, 'N');
T = args_has(args, 'T');
+ if (args_has(args, 'r'))
+ star = "";
if (args_has(args, 'r') && args_has(args, 'i'))
suffix = "/ri";
else if (args_has(args, 'r'))
@@ -71,34 +74,34 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
if (C && N && T) {
xasprintf(&filter->string,
"#{||:"
- "#{C%s:%s},#{||:#{m%s:*%s*,#{window_name}},"
- "#{m%s:*%s*,#{pane_title}}}}",
- suffix, s, suffix, s, suffix, s);
+ "#{C%s:%s},#{||:#{m%s:%s%s%s,#{window_name}},"
+ "#{m%s:%s%s%s,#{pane_title}}}}",
+ suffix, s, suffix, star, s, star, suffix, star, s, star);
} else if (C && N) {
xasprintf(&filter->string,
- "#{||:#{C%s:%s},#{m%s:*%s*,#{window_name}}}",
- suffix, s, suffix, s);
+ "#{||:#{C%s:%s},#{m%s:%s%s%s,#{window_name}}}",
+ suffix, s, suffix, star, s, star);
} else if (C && T) {
xasprintf(&filter->string,
- "#{||:#{C%s:%s},#{m%s:*%s*,#{pane_title}}}",
- suffix, s, suffix, s);
+ "#{||:#{C%s:%s},#{m%s:%s%s%s,#{pane_title}}}",
+ suffix, s, suffix, star, s, star);
} else if (N && T) {
xasprintf(&filter->string,
- "#{||:#{m%s:*%s*,#{window_name}},"
- "#{m%s:*%s*,#{pane_title}}}",
- suffix, s, suffix, s);
+ "#{||:#{m%s:%s%s%s,#{window_name}},"
+ "#{m%s:%s%s%s,#{pane_title}}}",
+ suffix, star, s, star, suffix, star, s, star);
} else if (C) {
xasprintf(&filter->string,
"#{C%s:%s}",
suffix, s);
} else if (N) {
xasprintf(&filter->string,
- "#{m%s:*%s*,#{window_name}}",
- suffix, s);
+ "#{m%s:%s%s%s,#{window_name}}",
+ suffix, star, s, star);
} else {
xasprintf(&filter->string,
- "#{m%s:*%s*,#{pane_title}}",
- suffix, s);
+ "#{m%s:%s%s%s,#{pane_title}}",
+ suffix, star, s, star);
}
new_args = args_create();