When choose-tree learnt the '-u; option to render the tree fully expanded,
it didn't then reset the current selection in the expanded tree to be that
of the current session and window.
This introduces a new function window_choose_set_current() which sets the
intended position of the selection when first rendered, and changes
window_choose_ready() to use it. It's then further used in choose-tree
when '-u' is given to set the selection to the correct position in the
expanded tree.
---
cmd-choose-tree.c | 5 ++++-
tmux.h | 2 ++
window-choose.c | 14 +++++++++++---
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index e2d382b..9afd838 100644
--- a/cmd-choose-tree.c
+++ b/cmd-choose-tree.c
@@ -231,9 +231,12 @@ windows_only:
free(final_win_template_last);
window_choose_ready(wl->window->active, cur_win, NULL);
+ window_choose_collapse_all(wl->window->active);
- if (args_has(args, 'u'))
+ if (args_has(args, 'u')) {
window_choose_expand_all(wl->window->active);
+ window_choose_set_current(wl->window->active, cur_win);
+ }
return (CMD_RETURN_NORMAL);
}
diff --git a/tmux.h b/tmux.h
index f0b9edf..d103311 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2253,6 +2253,8 @@ struct window_choose_data *window_choose_add_item(struct
window_pane *,
struct client *, struct winlink *, const char *,
const char *, u_int);
void window_choose_expand_all(struct window_pane *);
+void window_choose_collapse_all(struct window_pane *);
+void window_choose_set_current(struct window_pane *, u_int);
/* names.c */
void queue_window_name(struct window *);
diff --git a/window-choose.c b/window-choose.c
index 3c68d10..5ed85f0 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -44,7 +44,6 @@ void window_choose_scroll_down(struct window_pane *);
void window_choose_collapse(struct window_pane *, struct session *);
void window_choose_expand(struct window_pane *, struct session *, u_int);
-void window_choose_collapse_all(struct window_pane *);
enum window_choose_input_type {
WINDOW_CHOOSE_NORMAL = -1,
@@ -102,8 +101,7 @@ window_choose_add(struct window_pane *wp, struct
window_choose_data *wcd)
}
void
-window_choose_ready(struct window_pane *wp, u_int cur,
- void (*callbackfn)(struct window_choose_data *))
+window_choose_set_current(struct window_pane *wp, u_int cur)
{
struct window_choose_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
@@ -112,12 +110,22 @@ window_choose_ready(struct window_pane *wp, u_int cur,
if (data->selected > screen_size_y(s) - 1)
data->top = ARRAY_LENGTH(&data->list) - screen_size_y(s);
+ window_choose_redraw_screen(wp);
+}
+
+void
+window_choose_ready(struct window_pane *wp, u_int cur,
+ void (*callbackfn)(struct window_choose_data *))
+{
+ struct window_choose_mode_data *data = wp->modedata;
+
data->callbackfn = callbackfn;
if (data->callbackfn == NULL)
data->callbackfn = window_choose_default_callback;
ARRAY_CONCAT(&data->old_list, &data->list);
+ window_choose_set_current(wp, cur);
window_choose_collapse_all(wp);
}
--
1.7.11.4
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users