From 3bf64bbd84cfd7a3d30c8cfbd70cacd073bccb04 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 12 Sep 2019 14:15:08 +0300 Subject: [PATCH] Collapse the two implementations of Entry::set_edit_position --- source/entry.cpp | 17 +++-------------- source/entry.h | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/source/entry.cpp b/source/entry.cpp index 21064f7..19bb7cc 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -93,18 +93,6 @@ void Entry::erase(unsigned pos, unsigned len) if(multiline) check_view_range(); - - rebuild(); -} - -void Entry::set_edit_position(unsigned pos) -{ - edit_pos = min(pos, text.size()); - selection_active = false; - - if(multiline) - check_view_range(); - rebuild(); } @@ -390,8 +378,9 @@ void Entry::set_edit_position(unsigned ep, bool select) selection_pos = edit_pos; selection_active = select; - edit_pos = ep; - check_view_range(); + edit_pos = min(ep, text.size()); + if(multiline) + check_view_range(); rebuild(); } diff --git a/source/entry.h b/source/entry.h index a350ea8..b6b4998 100644 --- a/source/entry.h +++ b/source/entry.h @@ -63,7 +63,7 @@ public: void erase(unsigned, unsigned); const std::string &get_text() const { return text.get(); } - void set_edit_position(unsigned); + void set_edit_position(unsigned p) { set_edit_position(p, false); } unsigned get_edit_position() const { return edit_pos; } bool get_selection(unsigned &, unsigned &) const; -- 2.43.0