summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-11-28 21:02:41 +0000
committerMaxime Coste <frrrwww@gmail.com>2016-11-28 21:07:24 +0000
commitda6d7f4530f490ec262bd640f9c51d0bc3d5ef53 (patch)
treefbf9574b06af465ee19ee303c3372adfb77158d2
parent719eb16a5e66f4f5586ca0f338f344f154f2c080 (diff)
Always consider end of selection is not and eol for keep
Fixes #921
-rw-r--r--src/normal.cc6
-rw-r--r--test/regression/921-keep-empty-line-matches-all-lines/cmd1
-rw-r--r--test/regression/921-keep-empty-line-matches-all-lines/in3
-rw-r--r--test/regression/921-keep-empty-line-matches-all-lines/selections2
4 files changed, 10 insertions, 2 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 1b420faa..affe69c1 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -837,13 +837,15 @@ void keep(Context& context, NormalParams)
if (ex.empty())
return;
const Buffer& buffer = context.buffer();
+
Vector<Selection> keep;
for (auto& sel : context.selections())
{
auto begin = buffer.iterator_at(sel.min());
auto end = utf8::next(buffer.iterator_at(sel.max()), buffer.end());
- const auto flags = match_flags(is_bol(begin.coord()),
- is_eol(buffer, end.coord()),
+ // We do not consider if end is on an eol, as it seems to
+ // give more intuitive behaviours in keep use cases.
+ const auto flags = match_flags(is_bol(begin.coord()), false,
is_bow(buffer, begin.coord()),
is_eow(buffer, end.coord())) |
RegexConstant::match_any;
diff --git a/test/regression/921-keep-empty-line-matches-all-lines/cmd b/test/regression/921-keep-empty-line-matches-all-lines/cmd
new file mode 100644
index 00000000..c4c283ee
--- /dev/null
+++ b/test/regression/921-keep-empty-line-matches-all-lines/cmd
@@ -0,0 +1 @@
+%<a-s><a-k>^$<ret>
diff --git a/test/regression/921-keep-empty-line-matches-all-lines/in b/test/regression/921-keep-empty-line-matches-all-lines/in
new file mode 100644
index 00000000..80c448b6
--- /dev/null
+++ b/test/regression/921-keep-empty-line-matches-all-lines/in
@@ -0,0 +1,3 @@
+non-empty
+non-empty
+
diff --git a/test/regression/921-keep-empty-line-matches-all-lines/selections b/test/regression/921-keep-empty-line-matches-all-lines/selections
new file mode 100644
index 00000000..139597f9
--- /dev/null
+++ b/test/regression/921-keep-empty-line-matches-all-lines/selections
@@ -0,0 +1,2 @@
+
+