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)) {}