Only wrap pattern in *s if using a regular expression.

This commit is contained in:
nicm
2023-12-27 20:42:01 +00:00
parent f7bf7e9671
commit 40a20bc8ae

View File

@ -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 cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
const char *s = args_string(args, 0), *suffix = ""; const char *s = args_string(args, 0), *suffix = "";
const char *star = "*";
struct args_value *filter; struct args_value *filter;
int C, N, T; int C, N, T;
@ -55,6 +56,8 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
N = args_has(args, 'N'); N = args_has(args, 'N');
T = args_has(args, 'T'); T = args_has(args, 'T');
if (args_has(args, 'r'))
star = "";
if (args_has(args, 'r') && args_has(args, 'i')) if (args_has(args, 'r') && args_has(args, 'i'))
suffix = "/ri"; suffix = "/ri";
else if (args_has(args, 'r')) 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) { if (C && N && T) {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{||:" "#{||:"
"#{C%s:%s},#{||:#{m%s:*%s*,#{window_name}}," "#{C%s:%s},#{||:#{m%s:%s%s%s,#{window_name}},"
"#{m%s:*%s*,#{pane_title}}}}", "#{m%s:%s%s%s,#{pane_title}}}}",
suffix, s, suffix, s, suffix, s); suffix, s, suffix, star, s, star, suffix, star, s, star);
} else if (C && N) { } else if (C && N) {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{||:#{C%s:%s},#{m%s:*%s*,#{window_name}}}", "#{||:#{C%s:%s},#{m%s:%s%s%s,#{window_name}}}",
suffix, s, suffix, s); suffix, s, suffix, star, s, star);
} else if (C && T) { } else if (C && T) {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{||:#{C%s:%s},#{m%s:*%s*,#{pane_title}}}", "#{||:#{C%s:%s},#{m%s:%s%s%s,#{pane_title}}}",
suffix, s, suffix, s); suffix, s, suffix, star, s, star);
} else if (N && T) { } else if (N && T) {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{||:#{m%s:*%s*,#{window_name}}," "#{||:#{m%s:%s%s%s,#{window_name}},"
"#{m%s:*%s*,#{pane_title}}}", "#{m%s:%s%s%s,#{pane_title}}}",
suffix, s, suffix, s); suffix, star, s, star, suffix, star, s, star);
} else if (C) { } else if (C) {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{C%s:%s}", "#{C%s:%s}",
suffix, s); suffix, s);
} else if (N) { } else if (N) {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{m%s:*%s*,#{window_name}}", "#{m%s:%s%s%s,#{window_name}}",
suffix, s); suffix, star, s, star);
} else { } else {
xasprintf(&filter->string, xasprintf(&filter->string,
"#{m%s:*%s*,#{pane_title}}", "#{m%s:%s%s%s,#{pane_title}}",
suffix, s); suffix, star, s, star);
} }
new_args = args_create(); new_args = args_create();