From e0424ba01764f71421fee35ff5053e0b857ebc43 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 8 Apr 2014 20:09:54 +0100 Subject: [PATCH] Minor formatting fixes (very long lines) --- src/client_manager.cc | 4 +++- src/line_change_watcher.cc | 5 ++++- src/selection.cc | 6 ++++-- src/string.hh | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/client_manager.cc b/src/client_manager.cc index 9fe18ea7..12043456 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -97,7 +97,9 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) return res; } } - return WindowAndSelections{ std::unique_ptr{new Window{buffer}}, DynamicSelectionList{buffer, { Selection{ {}, {} } } } }; + return WindowAndSelections{ std::unique_ptr{new Window{buffer}}, + DynamicSelectionList{buffer, + { Selection{ {}, {} } } } }; } void ClientManager::add_free_window(std::unique_ptr&& window, SelectionList selections) diff --git a/src/line_change_watcher.cc b/src/line_change_watcher.cc index 3eeba883..af881a69 100644 --- a/src/line_change_watcher.cc +++ b/src/line_change_watcher.cc @@ -47,7 +47,10 @@ std::vector LineChangeWatcher::compute_modifications() } next = res.erase(next, delend); - const LineCount num_removed_from_added = std::min(num_removed, modif.new_line + modif.num_added - change.pos); + const LineCount num_added_after_pos = + modif.new_line + modif.num_added - change.pos; + const LineCount num_removed_from_added = + std::min(num_removed, num_added_after_pos); modif.num_added -= num_removed_from_added; modif.num_removed += num_removed - num_removed_from_added; diff --git a/src/selection.cc b/src/selection.cc index 52d8bc16..ec4af168 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -22,9 +22,11 @@ void on_buffer_change(const Buffer& buffer, SelectionList& sels, BufferCoord begin, BufferCoord end, LineCount end_line) { auto update_beg = std::lower_bound(sels.begin(), sels.end(), begin, - [](const Selection& s, BufferCoord c) { return std::max(s.anchor(), s.cursor()) < c; }); + [](const Selection& s, BufferCoord c) + { return s.max() < c; }); auto update_only_line_beg = std::upper_bound(sels.begin(), sels.end(), end_line, - [](LineCount l, const Selection& s) { return l < std::min(s.anchor(), s.cursor()).line; }); + [](LineCount l, const Selection& s) + { return l < s.min().line; }); if (update_beg != update_only_line_beg) { diff --git a/src/string.hh b/src/string.hh index 75f2e8b0..c7a7e1c2 100644 --- a/src/string.hh +++ b/src/string.hh @@ -49,7 +49,10 @@ public: memoryview data() const { return memoryview(std::string::data(), size()); } - String substr(ByteCount pos, ByteCount length = -1) const { return String{std::string::substr((int)pos, (int)length)}; } + String substr(ByteCount pos, ByteCount length = -1) const + { + return String{std::string::substr((int)pos, (int)length)}; + } String substr(CharCount pos, CharCount length = INT_MAX) const { auto b = utf8::advance(begin(), end(), (int)pos);