Skip to content

Commit

Permalink
Improve behaviour of auto and periodic refresh modes
Browse files Browse the repository at this point in the history
Closes jonas#389, closes jonas#441, closes jonas#794, closes jonas#888
  • Loading branch information
koutcher committed May 4, 2019
1 parent ea43f8b commit 284a914
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,11 @@ get_input(int prompt_position, struct key *key)
while (true) {
int delay = -1;

if (opt_refresh_mode == REFRESH_MODE_PERIODIC) {
if (opt_refresh_mode != REFRESH_MODE_MANUAL) {
bool refs_refreshed = false;

delay = watch_periodic(opt_refresh_interval);
if (opt_refresh_mode == REFRESH_MODE_PERIODIC)
delay = watch_periodic(opt_refresh_interval);

foreach_displayed_view (view, i) {
if (view_can_refresh(view) &&
Expand Down
8 changes: 6 additions & 2 deletions src/stage.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ stage_exists(struct view *view, struct status *status, enum line_type type)
if (parent == &status_view)
return status_exists(parent, status, type);

if (parent == &main_view)
if (parent == &main_view) {
refresh_view(&status_view);
return main_status_exists(parent, type);
}

return false;
}
Expand Down Expand Up @@ -459,8 +461,10 @@ stage_request(struct view *view, enum request request, struct line *line)

/* Check whether the staged entry still exists, and close the
* stage view if it doesn't. */
if (view->parent && !stage_exists(view, &stage_status, stage_line_type))
if (view->parent && !stage_exists(view, &stage_status, stage_line_type)) {
stage_line_type = 0;
return REQ_VIEW_CLOSE;
}

refresh_view(view);

Expand Down
8 changes: 4 additions & 4 deletions src/watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ static enum watch_trigger
watch_index_handler(struct watch_handler *handler, enum watch_event event, enum watch_trigger check)
{
enum watch_trigger changed = WATCH_NONE;
struct index_diff diff;
struct index_diff diff = { 0, 0, 0 };

if (event == WATCH_EVENT_AFTER_COMMAND)
return check_file_mtime(&handler->last_modified, "%s/index", repo.git_dir)
? check : WATCH_NONE;

if (!check_file_mtime(&handler->last_modified, "%s/index", repo.git_dir) ||
event == WATCH_EVENT_SWITCH_VIEW ||
!index_diff(&diff, opt_show_untracked, false))
if (event == WATCH_EVENT_SWITCH_VIEW ||
(!check_file_mtime(&handler->last_modified, "%s/index", repo.git_dir) &&
!index_diff(&diff, opt_show_untracked, false)))
return WATCH_NONE;

if (check & WATCH_INDEX_STAGED) {
Expand Down

0 comments on commit 284a914

Please sign in to comment.