1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 13:05:51 +03:00

[search] fix searching when a file is deleted and recreated

This commit is contained in:
Timothy Stack 2015-03-11 06:22:50 -07:00
parent 23344ac8b2
commit 974aafe1b9
3 changed files with 14 additions and 13 deletions

View File

@ -146,13 +146,13 @@ except OSError:
pass
FILES = [
(open("/tmp/demo/access_log", "w"), access_log_msgs()),
(open("/tmp/demo/messages", "w"), syslog_msgs()),
("/tmp/demo/access_log", access_log_msgs()),
("/tmp/demo/messages", syslog_msgs()),
]
while True:
for fp, gen in FILES:
for fname, gen in FILES:
for i in range(random.randrange(0, 4)):
fp.write(gen.next())
fp.flush()
with open(fname, "a+") as fp:
fp.write(gen.next())
time.sleep(random.uniform(0.25, 0.75))

View File

@ -233,7 +233,12 @@ void grep_proc::child_loop(void)
}
}
fprintf(stdout, "%d\n", line - 1);
if (stop_line == -1) {
// When scanning to the end of the source, we need to return the
// highest line that was seen so that the next request that
// continues from the end works properly.
fprintf(stdout, "h%d\n", line - 1);
}
this->child_term();
}
}
@ -281,12 +286,10 @@ void grep_proc::dispatch_line(char *line)
require(line != NULL);
if (sscanf(line, "%d", this->gp_last_line.out()) == 1) {
/* Starting a new line with matches. */
if (sscanf(line, "h%d", this->gp_highest_line.out()) == 1) {
if (this->gp_last_line > this->gp_highest_line) {
this->gp_highest_line = this->gp_last_line;
}
} else if (sscanf(line, "%d", this->gp_last_line.out()) == 1) {
/* Starting a new line with matches. */
ensure(this->gp_last_line >= 0);
}
else if (sscanf(line, "[%d:%d]", &start, &end) == 2) {

View File

@ -75,8 +75,6 @@ public:
* @param value_out The destination for the line value.
*/
virtual bool grep_value_for_line(int line, std::string &value_out) = 0;
virtual std::string grep_source_name(void) { return ""; };
};
/**