Selecting 'around' word when on spaces after word now selects next word
This commit is contained in:
parent
fcb37cc754
commit
696db111e2
|
@ -148,39 +148,24 @@ Selection select_word(const Buffer& buffer, const Selection& selection,
|
||||||
int count, ObjectFlags flags)
|
int count, ObjectFlags flags)
|
||||||
{
|
{
|
||||||
Utf8Iterator first{buffer.iterator_at(selection.cursor()), buffer};
|
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;
|
Utf8Iterator last = first;
|
||||||
if (is_word<word_type>(*first))
|
if (flags & ObjectFlags::ToBegin)
|
||||||
{
|
{
|
||||||
if (flags & ObjectFlags::ToBegin)
|
skip_while_reverse(first, buffer.begin(), is_word<word_type>);
|
||||||
{
|
if (not is_word<word_type>(*first))
|
||||||
skip_while_reverse(first, buffer.begin(), is_word<word_type>);
|
++first;
|
||||||
if (not is_word<word_type>(*first))
|
|
||||||
++first;
|
|
||||||
}
|
|
||||||
if (flags & ObjectFlags::ToEnd)
|
|
||||||
{
|
|
||||||
skip_while(last, buffer.end(), is_word<word_type>);
|
|
||||||
if (not (flags & ObjectFlags::Inner))
|
|
||||||
skip_while(last, buffer.end(), is_horizontal_blank);
|
|
||||||
--last;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (not (flags & ObjectFlags::Inner))
|
if (flags & ObjectFlags::ToEnd)
|
||||||
{
|
{
|
||||||
if (flags & ObjectFlags::ToBegin)
|
skip_while(last, buffer.end(), is_word<word_type>);
|
||||||
{
|
if (not (flags & ObjectFlags::Inner))
|
||||||
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);
|
skip_while(last, buffer.end(), is_horizontal_blank);
|
||||||
--last;
|
--last;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (flags & ObjectFlags::ToEnd) ? utf8_range(first, last)
|
return (flags & ObjectFlags::ToEnd) ? utf8_range(first, last)
|
||||||
: utf8_range(last, first);
|
: utf8_range(last, first);
|
||||||
|
|
1
test/unit/around/next-word/cmd
Normal file
1
test/unit/around/next-word/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<a-a>w
|
1
test/unit/around/next-word/in
Normal file
1
test/unit/around/next-word/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
foo%( )bar baz
|
1
test/unit/around/next-word/selections
Normal file
1
test/unit/around/next-word/selections
Normal file
|
@ -0,0 +1 @@
|
||||||
|
bar
|
Loading…
Reference in New Issue
Block a user