Skip to content

Commit

Permalink
Force reload of VIEW_FLEX_WIDTH views only when needed
Browse files Browse the repository at this point in the history
Reload is needed if split is vertical and number of views will change.
  • Loading branch information
koutcher committed May 19, 2019
1 parent 36ced9a commit 3b0f518
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,13 @@ update_view_title(struct view *view)
void
split_view(struct view *prev, struct view *view)
{
int height, width;
bool vsplit;
int nviews = displayed_views();

getmaxyx(stdscr, height, width);
vsplit = vertical_split_is_enabled(opt_vertical_split, height, width);

display[1] = view;
current_view = opt_focus_child ? 1 : 0;
view->parent = prev;
Expand All @@ -718,24 +725,31 @@ split_view(struct view *prev, struct view *view)
update_view_title(prev);
}

if (view_has_flags(prev, VIEW_FLEX_WIDTH))
if (view_has_flags(prev, VIEW_FLEX_WIDTH) && vsplit && nviews == 1)
load_view(prev, NULL, OPEN_RELOAD);
}

void
maximize_view(struct view *view, bool redraw)
{
int height, width;
bool vsplit;
int nviews = displayed_views();

getmaxyx(stdscr, height, width);
vsplit = vertical_split_is_enabled(opt_vertical_split, height, width);

memset(display, 0, sizeof(display));
current_view = 0;
display[current_view] = view;
resize_display();
if (redraw) {
redraw_display(false);
report_clear();

if (view_has_flags(view, VIEW_FLEX_WIDTH))
load_view(view, NULL, OPEN_RELOAD);
}

if (view_has_flags(view, VIEW_FLEX_WIDTH) && vsplit && nviews > 1)
load_view(view, NULL, OPEN_RELOAD);
}

void
Expand Down

0 comments on commit 3b0f518

Please sign in to comment.