Merge remote-tracking branch 'krobelus/textobject-count'
This commit is contained in:
commit
34baa56891
|
@ -494,7 +494,10 @@ select_sentence(const Context& context, const Selection& selection,
|
|||
|
||||
auto& buffer = context.buffer();
|
||||
BufferIterator first = buffer.iterator_at(selection.cursor());
|
||||
BufferIterator last;
|
||||
|
||||
for (++count; count > 0; --count)
|
||||
{
|
||||
if (not (flags & ObjectFlags::ToEnd) and first != buffer.begin())
|
||||
{
|
||||
BufferIterator prev_non_blank = first-1;
|
||||
|
@ -504,7 +507,8 @@ select_sentence(const Context& context, const Selection& selection,
|
|||
first = prev_non_blank;
|
||||
}
|
||||
|
||||
BufferIterator last = first;
|
||||
if (last == BufferIterator{})
|
||||
last = first;
|
||||
|
||||
if (flags & ObjectFlags::ToBegin)
|
||||
{
|
||||
|
@ -548,6 +552,7 @@ select_sentence(const Context& context, const Selection& selection,
|
|||
--last;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (flags & ObjectFlags::ToEnd) ? Selection{first.coord(), last.coord()}
|
||||
: Selection{last.coord(), first.coord()};
|
||||
}
|
||||
|
@ -558,7 +563,10 @@ select_paragraph(const Context& context, const Selection& selection,
|
|||
{
|
||||
auto& buffer = context.buffer();
|
||||
BufferIterator first = buffer.iterator_at(selection.cursor());
|
||||
BufferIterator last;
|
||||
|
||||
for (++count; count > 0; --count)
|
||||
{
|
||||
if (not (flags & ObjectFlags::ToEnd) and first.coord() > BufferCoord{0,1} and
|
||||
is_eol(*(first-1)) and first-1 != buffer.begin() and is_eol(*(first-2)))
|
||||
--first;
|
||||
|
@ -566,8 +574,8 @@ select_paragraph(const Context& context, const Selection& selection,
|
|||
first != buffer.begin() and (first+1) != buffer.end() and
|
||||
is_eol(*(first-1)) and is_eol(*first))
|
||||
++first;
|
||||
|
||||
BufferIterator last = first;
|
||||
if (last == BufferIterator{})
|
||||
last = first;
|
||||
|
||||
if ((flags & ObjectFlags::ToBegin) and first != buffer.begin())
|
||||
{
|
||||
|
@ -604,6 +612,7 @@ select_paragraph(const Context& context, const Selection& selection,
|
|||
}
|
||||
--last;
|
||||
}
|
||||
}
|
||||
return (flags & ObjectFlags::ToEnd) ? Selection{first.coord(), last.coord()}
|
||||
: Selection{last.coord(), first.coord()};
|
||||
}
|
||||
|
|
1
test/normal/object/end-extending/paragraph/count/cmd
Normal file
1
test/normal/object/end-extending/paragraph/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
2}p
|
7
test/normal/object/end-extending/paragraph/count/in
Normal file
7
test/normal/object/end-extending/paragraph/count/in
Normal file
|
@ -0,0 +1,7 @@
|
|||
%(a
|
||||
b)
|
||||
|
||||
c
|
||||
d
|
||||
|
||||
e
|
|
@ -0,0 +1,7 @@
|
|||
'a
|
||||
b
|
||||
|
||||
c
|
||||
d
|
||||
|
||||
'
|
1
test/normal/object/end-extending/sentence/count/cmd
Normal file
1
test/normal/object/end-extending/sentence/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
2}s
|
1
test/normal/object/end-extending/sentence/count/in
Normal file
1
test/normal/object/end-extending/sentence/count/in
Normal file
|
@ -0,0 +1 @@
|
|||
%(a b) c. d e. f.
|
|
@ -0,0 +1 @@
|
|||
'a b c. d e. '
|
1
test/normal/object/end/paragraph/count/cmd
Normal file
1
test/normal/object/end/paragraph/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
2]p
|
7
test/normal/object/end/paragraph/count/in
Normal file
7
test/normal/object/end/paragraph/count/in
Normal file
|
@ -0,0 +1,7 @@
|
|||
%(a)
|
||||
b
|
||||
|
||||
c
|
||||
d
|
||||
|
||||
e
|
|
@ -0,0 +1,7 @@
|
|||
'a
|
||||
b
|
||||
|
||||
c
|
||||
d
|
||||
|
||||
'
|
1
test/normal/object/end/paragraph/to-buffer-end/cmd
Normal file
1
test/normal/object/end/paragraph/to-buffer-end/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
9]p
|
4
test/normal/object/end/paragraph/to-buffer-end/in
Normal file
4
test/normal/object/end/paragraph/to-buffer-end/in
Normal file
|
@ -0,0 +1,4 @@
|
|||
%(a)
|
||||
b
|
||||
|
||||
c
|
|
@ -0,0 +1,5 @@
|
|||
'a
|
||||
b
|
||||
|
||||
c
|
||||
'
|
1
test/normal/object/end/sentence/count/cmd
Normal file
1
test/normal/object/end/sentence/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
<a-;>2]s
|
1
test/normal/object/end/sentence/count/in
Normal file
1
test/normal/object/end/sentence/count/in
Normal file
|
@ -0,0 +1 @@
|
|||
%(a b) c. d e. f g.
|
|
@ -0,0 +1 @@
|
|||
'a b c. d e. '
|
1
test/normal/object/end/sentence/to-buffer-end/cmd
Normal file
1
test/normal/object/end/sentence/to-buffer-end/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
9]s
|
3
test/normal/object/end/sentence/to-buffer-end/in
Normal file
3
test/normal/object/end/sentence/to-buffer-end/in
Normal file
|
@ -0,0 +1,3 @@
|
|||
a b.
|
||||
|
||||
c d.
|
|
@ -0,0 +1 @@
|
|||
'a b.'
|
1
test/normal/object/start-extending/paragraph/count/cmd
Normal file
1
test/normal/object/start-extending/paragraph/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
<a-;>2{p
|
7
test/normal/object/start-extending/paragraph/count/in
Normal file
7
test/normal/object/start-extending/paragraph/count/in
Normal file
|
@ -0,0 +1,7 @@
|
|||
a
|
||||
|
||||
b
|
||||
|
||||
c
|
||||
%(d
|
||||
e)
|
|
@ -0,0 +1,5 @@
|
|||
'b
|
||||
|
||||
c
|
||||
d
|
||||
e'
|
1
test/normal/object/start-extending/sentence/count/cmd
Normal file
1
test/normal/object/start-extending/sentence/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
<a-;>2{s
|
1
test/normal/object/start-extending/sentence/count/in
Normal file
1
test/normal/object/start-extending/sentence/count/in
Normal file
|
@ -0,0 +1 @@
|
|||
a b. c d. e %(f g)
|
|
@ -0,0 +1 @@
|
|||
'c d. e f g'
|
1
test/normal/object/start/paragraph/count/cmd
Normal file
1
test/normal/object/start/paragraph/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
2[p
|
8
test/normal/object/start/paragraph/count/in
Normal file
8
test/normal/object/start/paragraph/count/in
Normal file
|
@ -0,0 +1,8 @@
|
|||
a
|
||||
|
||||
b
|
||||
c
|
||||
|
||||
d
|
||||
%(e)
|
||||
f
|
|
@ -0,0 +1,5 @@
|
|||
'b
|
||||
c
|
||||
|
||||
d
|
||||
e'
|
1
test/normal/object/start/sentence/count/cmd
Normal file
1
test/normal/object/start/sentence/count/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
2[s
|
1
test/normal/object/start/sentence/count/in
Normal file
1
test/normal/object/start/sentence/count/in
Normal file
|
@ -0,0 +1 @@
|
|||
a b. c d. e %(f)
|
|
@ -0,0 +1 @@
|
|||
'c d. e f'
|
1
test/normal/object/start/sentence/to-buffer-begin/cmd
Normal file
1
test/normal/object/start/sentence/to-buffer-begin/cmd
Normal file
|
@ -0,0 +1 @@
|
|||
9[s
|
3
test/normal/object/start/sentence/to-buffer-begin/in
Normal file
3
test/normal/object/start/sentence/to-buffer-begin/in
Normal file
|
@ -0,0 +1,3 @@
|
|||
a b.
|
||||
|
||||
c d. %(e) f.
|
|
@ -0,0 +1,3 @@
|
|||
'a b.
|
||||
|
||||
c d.'
|
Loading…
Reference in New Issue
Block a user