highlight_range: handle empty ranges

This commit is contained in:
Maxime Coste 2012-08-10 14:20:15 +02:00
parent f59dd77f60
commit a30b3e1343

View File

@ -18,7 +18,8 @@ void highlight_range(DisplayBuffer& display_buffer,
BufferIterator begin, BufferIterator end, BufferIterator begin, BufferIterator end,
bool skip_replaced, T func) 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; return;
for (auto& line : display_buffer.lines()) for (auto& line : display_buffer.lines())
@ -59,7 +60,8 @@ void colorize_regex(DisplayBuffer& display_buffer, const Regex& ex,
BufferRange range = display_buffer.range(); BufferRange range = display_buffer.range();
const Buffer& buffer = range.first.buffer(); const Buffer& buffer = range.first.buffer();
range.first = buffer.iterator_at({ range.first.line() - 10, 0 }); 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_it(range.first, range.second, ex);
RegexIterator re_end; RegexIterator re_end;