Thomas Adam
2014-12-01 23:57:43 UTC
In the case of creating a new window, tmux would end up checking the window name
before the index. This is usually OK, save for the fact that if a window ever
has as its title, the same number as the index, then the check is in error.
Instead, make cmd_lookup_index() check the index and then the title; returning
early if the index matches.
---
cmd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmd.c b/cmd.c
index eeffe4c..ae0e4b1 100644
--- a/cmd.c
+++ b/cmd.c
@@ -711,15 +711,15 @@ cmd_lookup_index(struct session *s, const char *name, int *ambiguous)
const char *errstr;
u_int idx;
+ idx = strtonum(name, 0, INT_MAX, &errstr);
+ if (errstr == NULL)
+ return (idx);
+
if ((wl = cmd_lookup_window(s, name, ambiguous)) != NULL)
return (wl->idx);
if (*ambiguous)
return (-1);
- idx = strtonum(name, 0, INT_MAX, &errstr);
- if (errstr == NULL)
- return (idx);
-
return (-1);
}
before the index. This is usually OK, save for the fact that if a window ever
has as its title, the same number as the index, then the check is in error.
Instead, make cmd_lookup_index() check the index and then the title; returning
early if the index matches.
---
cmd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmd.c b/cmd.c
index eeffe4c..ae0e4b1 100644
--- a/cmd.c
+++ b/cmd.c
@@ -711,15 +711,15 @@ cmd_lookup_index(struct session *s, const char *name, int *ambiguous)
const char *errstr;
u_int idx;
+ idx = strtonum(name, 0, INT_MAX, &errstr);
+ if (errstr == NULL)
+ return (idx);
+
if ((wl = cmd_lookup_window(s, name, ambiguous)) != NULL)
return (wl->idx);
if (*ambiguous)
return (-1);
- idx = strtonum(name, 0, INT_MAX, &errstr);
- if (errstr == NULL)
- return (idx);
-
return (-1);
}
--
2.0.1
2.0.1