summaryrefslogtreecommitdiff
path: root/src/selection.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-08-27 11:19:07 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-08-27 11:20:38 +0100
commitb934bcd4e19f0ae3f740f9cc293b8c662aa1e1d0 (patch)
tree8c58676c228c6ef0e8fd9e935cda530b21d37ee6 /src/selection.cc
parent093d3bd0dfa766007d0efae414f1b464d7b2a189 (diff)
Support merging consecutive selections with <a-m>
Fixes #773
Diffstat (limited to 'src/selection.cc')
-rw-r--r--src/selection.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/selection.cc b/src/selection.cc
index e9e30ca9..9922e851 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -445,6 +445,18 @@ void SelectionList::merge_overlapping()
m_main, overlaps), end());
}
+void SelectionList::merge_consecutive()
+{
+ if (size() == 1)
+ return;
+
+ auto touches = [this](const Selection& lhs, const Selection& rhs) {
+ return m_buffer->char_next(lhs.max()) >= rhs.min();
+ };
+ m_selections.erase(Kakoune::merge_overlapping(begin(), end(),
+ m_main, touches), end());
+}
+
void SelectionList::sort_and_merge_overlapping()
{
sort();