From 1388c0d54051f748dd50a620f0b12e4f114550fe Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 12 Jul 2013 13:15:31 +0100 Subject: [PATCH] Editor: clamp coordinates in select(BufferCoord) --- src/editor.hh | 2 +- src/selection.hh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/editor.hh b/src/editor.hh index b527d513..d8785a87 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -62,7 +62,7 @@ public: void keep_selection(int index); void remove_selection(int index); void select(const BufferCoord& c, SelectMode mode = SelectMode::Replace) - { select(Selection{ c, c }, mode); } + { select(Selection{ buffer().clamp(c) }, mode); } void select(const Selection& sel, SelectMode mode = SelectMode::Replace); void select(const Selector& selector, diff --git a/src/selection.hh b/src/selection.hh index 3db23546..a95ee2aa 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -56,6 +56,7 @@ using CaptureList = std::vector; // A selection is a Range, associated with a CaptureList struct Selection : public Range { + explicit Selection(const BufferCoord& pos) : Range(pos,pos) {} Selection(const BufferCoord& first, const BufferCoord& last, CaptureList captures = {}) : Range(first, last), m_captures(std::move(captures)) {}