Skip to content

Commit

Permalink
[looper] increase rescan/rebuild delay when a prompt is open
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed Jun 8, 2021
1 parent b2d296b commit ace6394
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/lnav.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1682,12 +1682,10 @@ static void looper()
}
}
else {
bool got_user_input = false;
if (pollfd_ready(pollfds, STDIN_FILENO)) {
int ch;

next_status_update_time = ui_clock::now();
next_rescan_time = next_status_update_time + 1s;
next_rebuild_time = next_rescan_time;
while ((ch = getch()) != ERR) {
alerter::singleton().new_input(ch);

Expand All @@ -1704,6 +1702,27 @@ static void looper()
break;
}
}

got_user_input = true;
next_status_update_time = ui_clock::now();
switch (lnav_data.ld_mode) {
case LNM_PAGING:
case LNM_FILTER:
case LNM_FILES:
next_rescan_time = next_status_update_time + 1s;
break;
case LNM_COMMAND:
case LNM_SEARCH:
case LNM_SEARCH_FILTERS:
case LNM_SEARCH_FILES:
case LNM_CAPTURE:
case LNM_SQL:
case LNM_EXEC:
case LNM_USER:
next_rescan_time = next_status_update_time + 1min;
break;
}
next_rebuild_time = next_rescan_time;
}

for (auto &tc : lnav_data.ld_views) {
Expand All @@ -1714,10 +1733,24 @@ static void looper()
lnav_data.ld_bottom_source.update_hits(tc);
};

auto old_mode = lnav_data.ld_mode;
rlc.check_poll_set(pollfds);
lnav_data.ld_filter_source.fss_editor.check_poll_set(pollfds);
lnav_data.ld_filter_view.check_poll_set(pollfds);
lnav_data.ld_files_view.check_poll_set(pollfds);

if (lnav_data.ld_mode != old_mode) {
switch (lnav_data.ld_mode) {
case LNM_PAGING:
case LNM_FILTER:
case LNM_FILES:
next_rescan_time = next_status_update_time + 1s;
next_rebuild_time = next_rescan_time;
break;
default:
break;
}
}
}

if (timer.time_to_update(overlay_counter)) {
Expand Down

0 comments on commit ace6394

Please sign in to comment.