From a06094b00e92d34e9f0be6abf80e5f4ce64998b3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 13 May 2014 20:09:37 +0100 Subject: [PATCH] Use simple SelectionList for the Context::JumpList --- src/context.cc | 21 ++++++++++++++------- src/context.hh | 6 +++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/context.cc b/src/context.cc index dac65284..9dcc87e4 100644 --- a/src/context.cc +++ b/src/context.cc @@ -103,8 +103,7 @@ void Context::push_jump() if (m_current_jump != m_jump_list.end()) { auto begin = m_current_jump; - if (&buffer() != &begin->buffer() or - (const SelectionList&)(*begin) != jump) + if (&buffer() != &begin->buffer() or *begin != jump) ++begin; m_jump_list.erase(begin, m_jump_list.end()); } @@ -114,21 +113,27 @@ void Context::push_jump() m_current_jump = m_jump_list.end(); } -const DynamicSelectionList& Context::jump_forward() +const SelectionList& Context::jump_forward() { if (m_current_jump != m_jump_list.end() and m_current_jump + 1 != m_jump_list.end()) - return *++m_current_jump; + { + SelectionList& res = *++m_current_jump; + res.update(); + return res; + } throw runtime_error("no next jump"); } -const DynamicSelectionList& Context::jump_backward() +const SelectionList& Context::jump_backward() { if (m_current_jump != m_jump_list.end() and *m_current_jump != selections()) { push_jump(); - return *--m_current_jump; + SelectionList& res = *--m_current_jump; + res.update(); + return res; } if (m_current_jump != m_jump_list.begin()) { @@ -137,7 +142,9 @@ const DynamicSelectionList& Context::jump_backward() push_jump(); --m_current_jump; } - return *--m_current_jump; + SelectionList& res = *--m_current_jump; + res.update(); + return res; } throw runtime_error("no previous jump"); } diff --git a/src/context.hh b/src/context.hh index f612e36a..786386e2 100644 --- a/src/context.hh +++ b/src/context.hh @@ -64,8 +64,8 @@ public: void print_status(DisplayLine status) const; void push_jump(); - const DynamicSelectionList& jump_forward(); - const DynamicSelectionList& jump_backward(); + const SelectionList& jump_forward(); + const SelectionList& jump_backward(); void forget_jumps_to_buffer(Buffer& buffer); const String& name() const { return m_name; } @@ -89,7 +89,7 @@ private: String m_name; - using JumpList = std::vector; + using JumpList = std::vector; JumpList m_jump_list; JumpList::iterator m_current_jump = m_jump_list.begin(); };