Always consider end of selection is not and eol for keep

Fixes #921
This commit is contained in:
Maxime Coste 2016-11-28 21:02:41 +00:00
parent 719eb16a5e
commit da6d7f4530
4 changed files with 10 additions and 2 deletions

View File

@ -837,13 +837,15 @@ void keep(Context& context, NormalParams)
if (ex.empty()) if (ex.empty())
return; return;
const Buffer& buffer = context.buffer(); const Buffer& buffer = context.buffer();
Vector<Selection> keep; Vector<Selection> keep;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
auto begin = buffer.iterator_at(sel.min()); auto begin = buffer.iterator_at(sel.min());
auto end = utf8::next(buffer.iterator_at(sel.max()), buffer.end()); auto end = utf8::next(buffer.iterator_at(sel.max()), buffer.end());
const auto flags = match_flags(is_bol(begin.coord()), // We do not consider if end is on an eol, as it seems to
is_eol(buffer, end.coord()), // give more intuitive behaviours in keep use cases.
const auto flags = match_flags(is_bol(begin.coord()), false,
is_bow(buffer, begin.coord()), is_bow(buffer, begin.coord()),
is_eow(buffer, end.coord())) | is_eow(buffer, end.coord())) |
RegexConstant::match_any; RegexConstant::match_any;

View File

@ -0,0 +1 @@
%<a-s><a-k>^$<ret>

View File

@ -0,0 +1,3 @@
non-empty
non-empty