mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Fix filtering so it works after the change to only show windows if they
have multiple panes.
This commit is contained in:
		| @@ -478,7 +478,6 @@ options_match_get(struct options *oo, const char *s, int *idx, int only, | |||||||
| 	return (o); | 	return (o); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| const char * | const char * | ||||||
| options_get_string(struct options *oo, const char *name) | options_get_string(struct options *oo, const char *name) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -240,6 +240,23 @@ window_tree_build_pane(struct session *s, struct winlink *wl, | |||||||
| 	free(name); | 	free(name); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | 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 | static int | ||||||
| window_tree_build_window(struct session *s, struct winlink *wl, void* modedata, | window_tree_build_window(struct session *s, struct winlink *wl, void* modedata, | ||||||
|     u_int sort_type, struct mode_tree_item *parent, const char *filter) |     u_int sort_type, struct mode_tree_item *parent, const char *filter) | ||||||
| @@ -247,7 +264,7 @@ window_tree_build_window(struct session *s, struct winlink *wl, void* modedata, | |||||||
| 	struct window_tree_modedata	*data = modedata; | 	struct window_tree_modedata	*data = modedata; | ||||||
| 	struct window_tree_itemdata	*item; | 	struct window_tree_itemdata	*item; | ||||||
| 	struct mode_tree_item		*mti; | 	struct mode_tree_item		*mti; | ||||||
| 	char				*name, *text, *cp; | 	char				*name, *text; | ||||||
| 	struct window_pane		*wp, **l; | 	struct window_pane		*wp, **l; | ||||||
| 	u_int				 n, i; | 	u_int				 n, i; | ||||||
| 	int				 expanded; | 	int				 expanded; | ||||||
| @@ -271,30 +288,24 @@ window_tree_build_window(struct session *s, struct winlink *wl, void* modedata, | |||||||
| 	free(text); | 	free(text); | ||||||
| 	free(name); | 	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); | 		return (1); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	l = NULL; | 	l = NULL; | ||||||
| 	n = 0; | 	n = 0; | ||||||
|  |  | ||||||
| 	TAILQ_FOREACH(wp, &wl->window->panes, entry) { | 	TAILQ_FOREACH(wp, &wl->window->panes, entry) { | ||||||
| 		if (filter != NULL) { | 		if (!window_tree_filter_pane(s, wl, wp, filter)) | ||||||
| 			cp = format_single(NULL, filter, NULL, s, wl, wp); | 			continue; | ||||||
| 			if (!format_true(cp)) { |  | ||||||
| 				free(cp); |  | ||||||
| 				continue; |  | ||||||
| 			} |  | ||||||
| 			free(cp); |  | ||||||
| 		} |  | ||||||
| 		l = xreallocarray(l, n + 1, sizeof *l); | 		l = xreallocarray(l, n + 1, sizeof *l); | ||||||
| 		l[n++] = wp; | 		l[n++] = wp; | ||||||
| 	} | 	} | ||||||
| 	if (n == 0) { | 	if (n == 0) | ||||||
| 		window_tree_free_item(item); | 		goto empty; | ||||||
| 		data->item_size--; |  | ||||||
| 		mode_tree_remove(data->data, mti); |  | ||||||
| 		return (0); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	switch (sort_type) { | 	switch (sort_type) { | ||||||
| 	case WINDOW_TREE_BY_INDEX: | 	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); | 		window_tree_build_pane(s, wl, l[i], modedata, mti); | ||||||
| 	free(l); | 	free(l); | ||||||
| 	return (1); | 	return (1); | ||||||
|  |  | ||||||
|  | empty: | ||||||
|  | 	window_tree_free_item(item); | ||||||
|  | 	data->item_size--; | ||||||
|  | 	mode_tree_remove(data->data, mti); | ||||||
|  | 	return (0); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nicm
					nicm