diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-01-18 10:52:26 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-01-18 11:47:18 +0000 |
| commit | 2ac545d306f7742f0365abef9b02bab952786eda (patch) | |
| tree | 6d265a5c6a42873847bf625242bc87bc2f2195da /src | |
| parent | 5cffc48efc3f79eaa8c8d5dbb91e2289b5fccf5e (diff) | |
RegionHighlighter: correct coordinates that are one past end of line
As region highlighters store per lines matches, end of line ones
are not valid buffer coordinates and must be corrected as begining
of next line.
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index 1e7c43d8..553a6d27 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -536,13 +536,20 @@ public: if (flags != HighlightFlags::Highlight) return; auto range = display_buffer.range(); - auto& regions = update_cache_ifn(context.buffer()); + const auto& buffer = context.buffer(); + auto& regions = update_cache_ifn(buffer); 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; }); + auto correct = [&](const BufferCoord& c) { + if (buffer[c.line].length() == c.column) + return BufferCoord{c.line+1, 0}; + return c; + }; for (; begin != end; ++begin) - m_func(context, flags, display_buffer, begin->begin, begin->end); + m_func(context, flags, display_buffer, + correct(begin->begin), correct(begin->end)); } private: Regex m_begin; @@ -732,8 +739,10 @@ private: if (not erase) { it->timestamp = buf_timestamp; - kak_assert(buffer.is_valid({it->line, it->begin})); - kak_assert(buffer.is_valid({it->line, it->end})); + kak_assert(buffer.is_valid({it->line, it->begin}) or + buffer[it->line].length() == it->begin); + kak_assert(buffer.is_valid({it->line, it->end}) or + buffer[it->line].length() == it->end); if (ins_pos != it) *ins_pos = std::move(*it); |
