summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-03-03 21:13:16 +0000
committerMaxime Coste <mawww@kakoune.org>2017-03-03 21:13:16 +0000
commitf8a625bc2fdf65d3d3f8072f4fffb07682044e8a (patch)
treecf88de6bf28f76d14b1b6cb6f3a38b918526fea6 /src/normal.cc
parent7d07064a418191ec63f6f1914116e704465d598e (diff)
parent033b259e5b3848e8ed153ae6fd1423571b332f25 (diff)
Merge remote-tracking branch 'occivink/master'
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/normal.cc b/src/normal.cc
index ce588bb2..0ee22f59 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -1717,8 +1717,10 @@ void keep_selection(Context& context, NormalParams p)
{
auto& selections = context.selections();
const int index = p.count ? p.count-1 : selections.main_index();
- if (index < selections.size())
- selections = SelectionList{ selections.buffer(), std::move(selections[index]) };
+ if (index >= selections.size())
+ throw runtime_error{format("invalid selection index: {}", index)};
+
+ selections = SelectionList{ selections.buffer(), std::move(selections[index]) };
selections.check_invariant();
}
@@ -1726,9 +1728,8 @@ void remove_selection(Context& context, NormalParams p)
{
auto& selections = context.selections();
const int index = p.count ? p.count-1 : selections.main_index();
-
if (index >= selections.size())
- throw runtime_error{format("There is not {}th selection", index)};
+ throw runtime_error{format("invalid selection index: {}", index)};
if (selections.size() == 1)
throw runtime_error{"Cannot remove the last selection"};