Rework buggy number selection function

Fixes #765
Fixes #766
This commit is contained in:
Maxime Coste 2016-08-22 13:52:37 +01:00
parent 0de4fc75d0
commit 56a7c6e594

View File

@ -247,6 +247,10 @@ Selection select_number(const Buffer& buffer, const Selection& selection, Object
BufferIterator first = buffer.iterator_at(selection.cursor()); BufferIterator first = buffer.iterator_at(selection.cursor());
BufferIterator last = first; BufferIterator last = first;
if (not is_number(*first) and *first != '-')
return selection;
if (flags & ObjectFlags::ToBegin) if (flags & ObjectFlags::ToBegin)
{ {
skip_while_reverse(first, buffer.begin(), is_number); skip_while_reverse(first, buffer.begin(), is_number);
@ -257,7 +261,10 @@ Selection select_number(const Buffer& buffer, const Selection& selection, Object
if (flags & ObjectFlags::ToEnd) if (flags & ObjectFlags::ToEnd)
{ {
if (*last == '-')
++last;
skip_while(last, buffer.end(), is_number); skip_while(last, buffer.end(), is_number);
if (last != buffer.begin())
--last; --last;
} }