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/main.cc | |
| 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/main.cc')
| -rw-r--r-- | src/main.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main.cc b/src/main.cc index a6ffbacf..869dc75c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -274,8 +274,8 @@ void do_indent(Context& context) String indent(' ', width); Editor& editor = context.editor(); - SelectionList sels = editor.selections(); - auto restore_sels = on_scope_end([&]{ editor.select(std::move(sels)); }); + DynamicSelectionList sels{editor.buffer(), editor.selections()}; + auto restore_sels = on_scope_end([&]{ editor.select((SelectionList)std::move(sels)); }); editor.select(select_whole_lines); editor.multi_select(std::bind(select_all_matches, _1, "^[^\n]")); editor.insert(indent, InsertMode::Insert); @@ -285,8 +285,8 @@ void do_deindent(Context& context) { int width = context.options()["indentwidth"].as_int(); Editor& editor = context.editor(); - SelectionList sels = editor.selections(); - auto restore_sels = on_scope_end([&]{ editor.select(std::move(sels)); }); + DynamicSelectionList sels{editor.buffer(), editor.selections()}; + auto restore_sels = on_scope_end([&]{ editor.select((SelectionList)std::move(sels)); }); editor.select(select_whole_lines); editor.multi_select(std::bind(select_all_matches, _1, "^\\h{1," + int_to_str(width) + "}")); @@ -399,9 +399,9 @@ template<JumpDirection direction> void jump(Context& context) { auto jump = (direction == JumpDirection::Forward) ? - context.jump_forward() : context.jump_backward(); + context.jump_forward() : context.jump_backward(); - Buffer& buffer = const_cast<Buffer&>(jump.first().buffer()); + Buffer& buffer = const_cast<Buffer&>(jump.front().buffer()); BufferManager::instance().set_last_used_buffer(buffer); if (&buffer != &context.buffer()) { |
