Editor: clamp coordinates in select(BufferCoord)

This commit is contained in:
Maxime Coste 2013-07-12 13:15:31 +01:00
parent 0ba1ab04f0
commit 1388c0d540
2 changed files with 2 additions and 1 deletions

View File

@ -62,7 +62,7 @@ public:
void keep_selection(int index); void keep_selection(int index);
void remove_selection(int index); void remove_selection(int index);
void select(const BufferCoord& c, SelectMode mode = SelectMode::Replace) 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, void select(const Selection& sel,
SelectMode mode = SelectMode::Replace); SelectMode mode = SelectMode::Replace);
void select(const Selector& selector, void select(const Selector& selector,

View File

@ -56,6 +56,7 @@ using CaptureList = std::vector<String>;
// A selection is a Range, associated with a CaptureList // A selection is a Range, associated with a CaptureList
struct Selection : public Range struct Selection : public Range
{ {
explicit Selection(const BufferCoord& pos) : Range(pos,pos) {}
Selection(const BufferCoord& first, const BufferCoord& last, Selection(const BufferCoord& first, const BufferCoord& last,
CaptureList captures = {}) CaptureList captures = {})
: Range(first, last), m_captures(std::move(captures)) {} : Range(first, last), m_captures(std::move(captures)) {}