summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2013-06-05 21:36:29 +0200
committercos <cos>2014-03-02 20:30:04 +0100
commit4c2a7e2167292e3aa40398f0e31b04af93853fc5 (patch)
treec7a610ce930eec17a00ca51c2bf438a4e367edbc
parent3cee18b208f1c8e3147b13148130ba12a7dcf6e2 (diff)
downloadratpoison-fix/gselect_exact_match.zip
Allow exact matching with gselect.fix/gselect_exact_match
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.
-rw-r--r--src/actions.c9
1 files 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)