From 56a7c6e594d9ff0d048d3bdf5513d5322bba0fb3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 22 Aug 2016 13:52:37 +0100 Subject: [PATCH] Rework buggy number selection function Fixes #765 Fixes #766 --- src/selectors.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/selectors.cc b/src/selectors.cc index d4725c5e..24319037 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -247,6 +247,10 @@ Selection select_number(const Buffer& buffer, const Selection& selection, Object BufferIterator first = buffer.iterator_at(selection.cursor()); BufferIterator last = first; + + if (not is_number(*first) and *first != '-') + return selection; + if (flags & ObjectFlags::ToBegin) { skip_while_reverse(first, buffer.begin(), is_number); @@ -257,8 +261,11 @@ Selection select_number(const Buffer& buffer, const Selection& selection, Object if (flags & ObjectFlags::ToEnd) { + if (*last == '-') + ++last; skip_while(last, buffer.end(), is_number); - --last; + if (last != buffer.begin()) + --last; } return (flags & ObjectFlags::ToEnd) ? Selection{first.coord(), last.coord()}