Fix select_number crashing on empty buffers

This commit is contained in:
Maxime Coste 2015-04-20 13:55:42 +01:00
parent ddd70fd09a
commit d2e8bd2431

View File

@ -229,13 +229,15 @@ Selection select_number(const Buffer& buffer, const Selection& selection, Object
};
BufferIterator first = buffer.iterator_at(selection.cursor());
BufferIterator last = first;
if (flags & ObjectFlags::ToBegin)
{
skip_while_reverse(first, buffer.begin(), is_number);
if (not is_number(*first) and *first != '-')
if (not is_number(*first) and *first != '-' and
first+1 != buffer.end())
++first;
}
BufferIterator last = buffer.iterator_at(selection.cursor());
if (flags & ObjectFlags::ToEnd)
{
skip_while(last, buffer.end(), is_number);