mirror of
https://github.com/tstack/lnav
synced 2024-11-03 23:15:38 +00:00
[filters] clear the state for filters that have been deleted
Fixes #292
This commit is contained in:
parent
82b94bfe63
commit
89be76ef42
@ -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;
|
||||
};
|
||||
|
@ -1890,6 +1890,19 @@ static string com_zoom_to(string cmdline, vector<string> &args)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static string com_reset_session(string cmdline, vector<string> &args)
|
||||
{
|
||||
if (args.empty()) {
|
||||
|
||||
}
|
||||
else {
|
||||
reset_session();
|
||||
lnav_data.ld_views[LNV_LOG].reload_data();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
static string com_load_session(string cmdline, vector<string> &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,
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -208,6 +208,17 @@ check_output "filter-in vmk is not working" <<EOF
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":filter-in vmk" \
|
||||
-c ":reset-session" \
|
||||
-c ":filter-in cgi" \
|
||||
${test_dir}/logfile_access_log.0
|
||||
|
||||
check_output "filter-in vmk is not working" <<EOF
|
||||
192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7"
|
||||
EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":filter-in today" \
|
||||
${test_dir}/logfile_multiline.0
|
||||
|
Loading…
Reference in New Issue
Block a user