diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-12-11 19:51:59 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-12-13 18:50:27 +0100 |
| commit | cfd7ee049a7c668bb2269029d159b34d2014ece6 (patch) | |
| tree | dc8d3eef1af8318acde758de012db858d4c36e30 /src/context.hh | |
| parent | e36bc74f431e2f98f049724536da86af9051811d (diff) | |
move selection updating code out of selection, to DynamicSelectionList
this avoids a lot of unnecessary (add|remove)_change_listener as
creating temporary Selections do not call that anymore.
Use can choose between a SelectionList which or a DynamicSelectionList
depending on wethear the buffer will be modified or not during the
selections lifetime.
Diffstat (limited to 'src/context.hh')
| -rw-r--r-- | src/context.hh | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/context.hh b/src/context.hh index cd33deec..079847f2 100644 --- a/src/context.hh +++ b/src/context.hh @@ -99,23 +99,21 @@ struct Context void push_jump() { - const Selection& jump = editor().selections().back(); + const SelectionList& jump = editor().selections(); if (m_current_jump != m_jump_list.end()) { auto begin = m_current_jump; - // when jump overlaps with m_current_jump, we replace m_current_jump - // instead of pushing after it. - if (&begin->first().buffer() != &jump.first().buffer() or - not overlaps(*begin, jump)) + if (&editor().buffer() != &begin->buffer() or + (const SelectionList&)(*begin) != jump) ++begin; m_jump_list.erase(begin, m_jump_list.end()); } - m_jump_list.push_back(jump); + m_jump_list.push_back({editor().buffer(), jump}); m_current_jump = m_jump_list.end(); } - Selection jump_forward() + const SelectionList& jump_forward() { if (m_current_jump != m_jump_list.end() and m_current_jump + 1 != m_jump_list.end()) @@ -123,7 +121,7 @@ struct Context throw runtime_error("no next jump"); } - Selection jump_backward() + const SelectionList& jump_backward() { if (m_current_jump != m_jump_list.begin()) { @@ -141,7 +139,7 @@ struct Context { for (auto it = m_jump_list.begin(); it != m_jump_list.end();) { - if (&it->first().buffer() == &buffer) + if (&it->buffer() == &buffer) { if (it < m_current_jump) --m_current_jump; @@ -164,8 +162,9 @@ private: Insertion m_last_insert = {InsertMode::Insert, {}}; int m_numeric_param = 0; - SelectionList m_jump_list; - SelectionList::iterator m_current_jump = m_jump_list.begin(); + using JumpList = std::vector<DynamicSelectionList>; + JumpList m_jump_list; + JumpList::iterator m_current_jump = m_jump_list.begin(); }; } |
