Selecting 'around' word when on spaces after word now selects next word

This commit is contained in:
Maxime Coste 2016-09-26 23:33:28 +01:00
parent fcb37cc754
commit 696db111e2
4 changed files with 16 additions and 28 deletions

View File

@ -148,9 +148,12 @@ Selection select_word(const Buffer& buffer, const Selection& selection,
int count, ObjectFlags flags)
{
Utf8Iterator first{buffer.iterator_at(selection.cursor()), buffer};
if (not is_word<word_type>(*first) and
not skip_while(first, buffer.end(), [](Codepoint c)
{ return not is_word<word_type>(c); }))
return selection;
Utf8Iterator last = first;
if (is_word<word_type>(*first))
{
if (flags & ObjectFlags::ToBegin)
{
skip_while_reverse(first, buffer.begin(), is_word<word_type>);
@ -164,24 +167,6 @@ Selection select_word(const Buffer& buffer, const Selection& selection,
skip_while(last, buffer.end(), is_horizontal_blank);
--last;
}
}
else if (not (flags & ObjectFlags::Inner))
{
if (flags & ObjectFlags::ToBegin)
{
skip_while_reverse(first, buffer.begin(), is_horizontal_blank);
if (not is_word<word_type>(*first))
return selection;
skip_while_reverse(first, buffer.begin(), is_word<word_type>);
if (not is_word<word_type>(*first))
++first;
}
if (flags & ObjectFlags::ToEnd)
{
skip_while(last, buffer.end(), is_horizontal_blank);
--last;
}
}
return (flags & ObjectFlags::ToEnd) ? utf8_range(first, last)
: utf8_range(last, first);
}

View File

@ -0,0 +1 @@
<a-a>w

View File

@ -0,0 +1 @@
foo%( )bar baz

View File

@ -0,0 +1 @@
bar