diff --git a/src/filter_observer.hh b/src/filter_observer.hh index 3efdb0ff..9690d40d 100644 --- a/src/filter_observer.hh +++ b/src/filter_observer.hh @@ -99,6 +99,17 @@ public: return retval; }; + void clear_deleted_filter_state() { + uint32_t used_mask = 0; + + for (filter_stack::iterator iter = this->lfo_filter_stack.begin(); + iter != this->lfo_filter_stack.end(); + ++iter) { + used_mask |= (1L << (*iter)->get_index()); + } + this->lfo_filter_state.clear_deleted_filter_state(used_mask); + }; + filter_stack &lfo_filter_stack; logfile_filter_state lfo_filter_state; }; diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index bc3f19a2..e4aad461 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -1890,6 +1890,19 @@ static string com_zoom_to(string cmdline, vector &args) return retval; } +static string com_reset_session(string cmdline, vector &args) +{ + if (args.empty()) { + + } + else { + reset_session(); + lnav_data.ld_views[LNV_LOG].reload_data(); + } + + return ""; +} + static string com_load_session(string cmdline, vector &args) { if (args.empty()) { @@ -2519,6 +2532,12 @@ readline_context::command_t STD_COMMANDS[] = { "Switch to the given view", com_switch_to_view, }, + { + "reset-session", + NULL, + "Reset the session state, clearing all filters, highlights, and bookmarks", + com_reset_session, + }, { "load-session", NULL, diff --git a/src/logfile_sub_source.cc b/src/logfile_sub_source.cc index 6beaaab5..21924a99 100644 --- a/src/logfile_sub_source.cc +++ b/src/logfile_sub_source.cc @@ -659,6 +659,7 @@ void logfile_sub_source::text_filters_changed() logfile *lf = ld->get_file(); if (lf != NULL) { + ld->ld_filter_state.clear_deleted_filter_state(); lf->reobserve_from(lf->begin() + ld->ld_filter_state.get_min_count(lf->size())); } } diff --git a/src/logfile_sub_source.hh b/src/logfile_sub_source.hh index 49127b01..3cc7876a 100644 --- a/src/logfile_sub_source.hh +++ b/src/logfile_sub_source.hh @@ -377,10 +377,6 @@ public: size_t ld_file_index; line_filter_observer ld_filter_state; size_t ld_lines_indexed; - struct { - content_line_t ld_start; - content_line_t ld_last; - } ld_indexing; bool ld_enabled; }; diff --git a/src/textfile_sub_source.hh b/src/textfile_sub_source.hh index abc25643..faf9ea08 100644 --- a/src/textfile_sub_source.hh +++ b/src/textfile_sub_source.hh @@ -220,6 +220,7 @@ public: line_filter_observer *lfo = (line_filter_observer *) lf->get_logline_observer(); uint32_t filter_in_mask, filter_out_mask; + lfo->clear_deleted_filter_state(); lf->reobserve_from(lf->begin() + lfo->get_min_count(lf->size())); this->get_filters().get_enabled_mask(filter_in_mask, filter_out_mask); diff --git a/src/textview_curses.hh b/src/textview_curses.hh index ce26cf74..8bbc50fe 100644 --- a/src/textview_curses.hh +++ b/src/textview_curses.hh @@ -56,8 +56,20 @@ public: this->tfs_logfile = NULL; memset(this->tfs_filter_count, 0, sizeof(this->tfs_filter_count)); this->tfs_mask.clear(); + this->tfs_index.clear(); }; + void clear_deleted_filter_state(uint32_t used_mask) { + for (int lpc = 0; lpc < MAX_FILTERS; lpc++) { + if (!(used_mask & (1L << lpc))) { + this->tfs_filter_count[lpc] = 0; + } + } + for (size_t lpc = 0; lpc < this->tfs_mask.size(); lpc++) { + this->tfs_mask[lpc] &= used_mask; + } + } + void resize(size_t newsize) { size_t old_mask_size = this->tfs_mask.size(); diff --git a/test/test_cmds.sh b/test/test_cmds.sh index 19f94fef..36a7e810 100644 --- a/test/test_cmds.sh +++ b/test/test_cmds.sh @@ -208,6 +208,17 @@ check_output "filter-in vmk is not working" <