diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-12-20 19:27:13 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-12-20 19:27:13 +0000 |
| commit | 7116ed6d61777b09bdc424bf18e3aaef2ed20a5b (patch) | |
| tree | 6c41c09b399476771445553824595ead771b3e5b /src | |
| parent | 42a24895de84f0bcaae6f04621dda07d30e0afdd (diff) | |
Window: throw when multiselect results in no selections
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/window.cc b/src/window.cc index d5c4b666..bcdfc137 100644 --- a/src/window.cc +++ b/src/window.cc @@ -236,6 +236,11 @@ void Window::select(const Selector& selector, bool append) scroll_to_keep_cursor_visible_ifn(); } +struct nothing_selected : public runtime_error +{ + nothing_selected() : runtime_error("nothing was selected") {} +}; + void Window::multi_select(const MultiSelector& selector) { check_invariant(); @@ -247,11 +252,11 @@ void Window::multi_select(const MultiSelector& selector) std::copy(selections.begin(), selections.end(), std::back_inserter(new_selections)); } - if (not new_selections.empty()) - { - m_selections = std::move(new_selections); - scroll_to_keep_cursor_visible_ifn(); - } + if (new_selections.empty()) + throw nothing_selected(); + + m_selections = std::move(new_selections); + scroll_to_keep_cursor_visible_ifn(); } BufferString Window::selection_content() const |
