From a30b3e1343cca910b5a00df48ab39378e9d7a067 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 10 Aug 2012 14:20:15 +0200 Subject: [PATCH] highlight_range: handle empty ranges --- src/highlighters.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index bffe2a681..a36443b4e 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -18,7 +18,8 @@ void highlight_range(DisplayBuffer& display_buffer, BufferIterator begin, BufferIterator end, bool skip_replaced, T func) { - if (end <= display_buffer.range().first or begin >= display_buffer.range().second) + if (begin == end or end <= display_buffer.range().first + or begin >= display_buffer.range().second) return; for (auto& line : display_buffer.lines()) @@ -59,7 +60,8 @@ void colorize_regex(DisplayBuffer& display_buffer, const Regex& ex, BufferRange range = display_buffer.range(); const Buffer& buffer = range.first.buffer(); range.first = buffer.iterator_at({ range.first.line() - 10, 0 }); - range.second = buffer.iterator_at({ range.second.line() + 10, 0 }); + range.second = buffer.iterator_at({ range.second.line() + 10, + range.second.column() }); RegexIterator re_it(range.first, range.second, ex); RegexIterator re_end;