[search] start searching a couple thousand lines before the top

This commit is contained in:
Timothy Stack 2020-09-14 21:29:06 -07:00
parent c18850aa01
commit cc7cba6514
2 changed files with 16 additions and 8 deletions

View File

@ -44,7 +44,7 @@
template<typename T, class DISTINCT>
class strong_int {
public:
explicit constexpr strong_int(T v = 0) : value(v) { };
explicit constexpr strong_int(T v = 0) noexcept : value(v) { };
operator const T &() const { return this->value; };
strong_int operator+(const strong_int &rhs)
{
@ -72,17 +72,17 @@ public:
this->value -= rhs.value;
return *this;
};
strong_int &operator-(void)
strong_int &operator-()
{
this->value = -this->value;
return *this;
};
strong_int &operator++(void) { this->value++; return *this; };
strong_int &operator--(void) { this->value--; return *this; };
strong_int &operator++() { this->value++; return *this; };
strong_int &operator--() { this->value--; return *this; };
bool operator==(const strong_int &rhs) const {
return this->value == rhs.value;
};
T *out(void) { return &this->value; };
T *out() { return &this->value; };
private:
T value;
};

View File

@ -44,6 +44,8 @@
using namespace std;
const auto REVERSE_SEARCH_OFFSET = 2000_vl;
void
text_filter::revert_to_last(logfile_filter_state &lfs, size_t rollback_size)
{
@ -470,9 +472,15 @@ void textview_curses::execute_search(const std::string &regex_orig)
unique_ptr<grep_proc<vis_line_t>> gp = make_unique<grep_proc<vis_line_t>>(code, *this);
gp->set_sink(this);
gp->queue_request(this->get_top());
if (this->get_top() > 0) {
gp->queue_request(0_vl, this->get_top());
auto top = this->get_top();
if (top < REVERSE_SEARCH_OFFSET) {
top = 0_vl;
} else {
top -= REVERSE_SEARCH_OFFSET;
}
gp->queue_request(top);
if (top > 0) {
gp->queue_request(0_vl, top);
}
gp->start();