From 4c2a7e2167292e3aa40398f0e31b04af93853fc5 Mon Sep 17 00:00:00 2001 From: cos Date: Wed, 5 Jun 2013 21:36:29 +0200 Subject: Allow exact matching with gselect. When having two groups where the second one's name partially matches the name of the first one, it is hard to gselect the second one. Similarly it is not possible to select groups with fully numerical names. e.g. If having the group list: 0-default 1*other 2-de 3-0 The user expactation when typing ":gselect de" or ":gselect 0" would likely be to select group number 2 & group number 3 respectively. This commit modifies the behaviour of gselect, to primarily select the group with an exactly matching name if possible, before trying numerical or partial matches. --- src/actions.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/actions.c b/src/actions.c index 8917b85..bfff2de 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1982,14 +1982,19 @@ read_gravity (struct argspec *spec, struct sbuf *s, struct cmdarg **arg) return cmdret_new (RET_SUCCESS, NULL); } -/* Given a string, find a matching group. First check if the string is - a number, then check if it's the name of a group. */ +/* Given a string, find a matching group. First check if the string exactly + matches a group name, then check if it is a number & lastly check if it + partially matches the name of a group. */ static rp_group * find_group (char *str) { rp_group *group; int n; + /* Exact matches are special cases. */ + if (group = groups_find_group_by_name (str, 1)) + return group; + /* Check if the user typed a group number. */ n = string_to_window_number (str); if (n >= 0) -- cgit v1.2.3