summaryrefslogtreecommitdiff
path: root/src/selection.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-06-11 12:01:40 +0100
committerMaxime Coste <mawww@kakoune.org>2017-06-11 12:01:40 +0100
commit63a791d65118bf37606db36ee12287e890d528ea (patch)
tree3812cb83f684486484b7ab099d768e98e7fca982 /src/selection.cc
parentb4647a16dda162c78fd7628f1ebb7325e95ba38c (diff)
Fix the Buffer::end() madness
Until now, buffer had multiple recognized end coordinates, either { line_count, 0 } or { line_count - 1, line[line_count - 1].length }. Now the only correct end coord is { line_count, 0 }, removing the need for various special cases.
Diffstat (limited to 'src/selection.cc')
-rw-r--r--src/selection.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/selection.cc b/src/selection.cc
index 05095dfa..4724e896 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -448,17 +448,15 @@ void SelectionList::erase()
kak_assert(m_buffer->is_valid(sel.cursor()));
auto pos = Kakoune::erase(*m_buffer, sel);
- sel.anchor() = sel.cursor() = m_buffer->clamp(pos);
+ sel.anchor() = sel.cursor() = pos;
changes_tracker.update(*m_buffer, m_timestamp);
}
BufferCoord back_coord = m_buffer->back_coord();
for (auto& sel : m_selections)
{
- if (sel.anchor() > back_coord)
- sel.anchor() = back_coord;
- if (sel.cursor() > back_coord)
- sel.cursor() = back_coord;
+ auto pos = m_buffer->clamp(sel.cursor());
+ sel.anchor() = sel.cursor() = std::min(pos, back_coord);
}
m_buffer->check_invariant();