summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-08-09 13:44:36 +0000
committernicm <nicm@openbsd.org>2017-08-09 13:44:36 +0000
commitf5b434027c9d032fba93d1f8ae966689313f3c88 (patch)
tree9c54858286fbb261ef9f647dc7d1cbab462d6469
parentExplain how to transform markup for the terminal when not using a (diff)
downloadwireguard-openbsd-f5b434027c9d032fba93d1f8ae966689313f3c88.tar.xz
wireguard-openbsd-f5b434027c9d032fba93d1f8ae966689313f3c88.zip
Fix filtering so it works after the change to only show windows if they
have multiple panes.
-rw-r--r--usr.bin/tmux/options.c3
-rw-r--r--usr.bin/tmux/window-tree.c51
2 files changed, 35 insertions, 19 deletions
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index 729e032e0ae..0fbb6449b57 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.35 2017/05/31 17:56:48 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.36 2017/08/09 13:44:36 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -478,7 +478,6 @@ options_match_get(struct options *oo, const char *s, int *idx, int only,
return (o);
}
-
const char *
options_get_string(struct options *oo, const char *name)
{
diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c
index 2384581089e..b4004535c6d 100644
--- a/usr.bin/tmux/window-tree.c
+++ b/usr.bin/tmux/window-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-tree.c,v 1.15 2017/08/09 11:43:45 nicm Exp $ */
+/* $OpenBSD: window-tree.c,v 1.16 2017/08/09 13:44:36 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -241,13 +241,30 @@ window_tree_build_pane(struct session *s, struct winlink *wl,
}
static int
+window_tree_filter_pane(struct session *s, struct winlink *wl,
+ struct window_pane *wp, const char *filter)
+{
+ char *cp;
+ int result;
+
+ if (filter == NULL)
+ return (1);
+
+ cp = format_single(NULL, filter, NULL, s, wl, wp);
+ result = format_true(cp);
+ free(cp);
+
+ return (result);
+}
+
+static int
window_tree_build_window(struct session *s, struct winlink *wl, void* modedata,
u_int sort_type, struct mode_tree_item *parent, const char *filter)
{
struct window_tree_modedata *data = modedata;
struct window_tree_itemdata *item;
struct mode_tree_item *mti;
- char *name, *text, *cp;
+ char *name, *text;
struct window_pane *wp, **l;
u_int n, i;
int expanded;
@@ -271,30 +288,24 @@ window_tree_build_window(struct session *s, struct winlink *wl, void* modedata,
free(text);
free(name);
- if (window_count_panes(wl->window) == 1)
+ wp = TAILQ_FIRST(&wl->window->panes);
+ if (TAILQ_NEXT(wp, entry) == NULL) {
+ if (!window_tree_filter_pane(s, wl, wp, filter))
+ goto empty;
return (1);
+ }
l = NULL;
n = 0;
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
- if (filter != NULL) {
- cp = format_single(NULL, filter, NULL, s, wl, wp);
- if (!format_true(cp)) {
- free(cp);
- continue;
- }
- free(cp);
- }
+ if (!window_tree_filter_pane(s, wl, wp, filter))
+ continue;
l = xreallocarray(l, n + 1, sizeof *l);
l[n++] = wp;
}
- if (n == 0) {
- window_tree_free_item(item);
- data->item_size--;
- mode_tree_remove(data->data, mti);
- return (0);
- }
+ if (n == 0)
+ goto empty;
switch (sort_type) {
case WINDOW_TREE_BY_INDEX:
@@ -311,6 +322,12 @@ window_tree_build_window(struct session *s, struct winlink *wl, void* modedata,
window_tree_build_pane(s, wl, l[i], modedata, mti);
free(l);
return (1);
+
+empty:
+ window_tree_free_item(item);
+ data->item_size--;
+ mode_tree_remove(data->data, mti);
+ return (0);
}
static void