diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-01-17 23:39:01 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-01-17 23:39:01 +0000 |
| commit | e1eec8903a2a15efe0f71809794601c34aaadfb1 (patch) | |
| tree | 9e44097ccc7cdd289cf3cf7f5ef61a21f7cb57a4 /src | |
| parent | 79c6d609c9749d51f142e56fa647b007277696c8 (diff) | |
only highlight actually displayed regions
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index e1862cf2..170b5cec 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -525,9 +525,14 @@ public: void operator()(const Context& context, DisplayBuffer& display_buffer) { + auto range = display_buffer.range(); auto& regions = update_cache_ifn(context.buffer()); - for (auto& region : regions) - m_func(context, display_buffer, region.begin, region.end); + auto begin = std::lower_bound(regions.begin(), regions.end(), range.first, + [](const Region& r, const BufferCoord& c) { return r.end < c; }); + auto end = std::lower_bound(begin, regions.end(), range.second, + [](const Region& r, const BufferCoord& c) { return r.begin < c; }); + for (; begin != end; ++begin) + m_func(context, display_buffer, begin->begin, begin->end); } private: Regex m_begin; |
