Merge remote-tracking branch 'Delapouite/sels'

This commit is contained in:
Maxime Coste 2018-02-26 11:34:05 +11:00
commit 18f0902824

View File

@ -1737,7 +1737,8 @@ void combine_selections(Context& context, SelectionList list, Func func)
else else
{ {
if (list.size() != sels.size()) if (list.size() != sels.size())
throw runtime_error{"The two selection lists don't have the same number of elements"}; throw runtime_error{format("The two selection lists don't have the same number of elements ({} vs {})",
list.size(), sels.size())};
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
combine_selection(sels.buffer(), list[i], sels[i], op); combine_selection(sels.buffer(), list[i], sels[i], op);
list.set_main_index(sels.main_index()); list.set_main_index(sels.main_index());
@ -1768,7 +1769,9 @@ void save_selections(Context& context, NormalParams params)
context.buffer().name(), context.buffer().name(),
context.buffer().timestamp()); context.buffer().timestamp());
RegisterManager::instance()[reg].set(context, desc); RegisterManager::instance()[reg].set(context, desc);
context.print_status({format("{} selections to register '{}'", combine ? "Combined" : "Saved", reg), get_face("Information")}); context.print_status({format("{} {} selections to register '{}'",
combine ? "Combined" : "Saved", sels.size(), reg),
get_face("Information")});
}; };
if (combine and not empty) if (combine and not empty)
@ -1784,8 +1787,11 @@ void restore_selections(Context& context, NormalParams params)
auto selections = read_selections_from_register(reg, context); auto selections = read_selections_from_register(reg, context);
auto set_selections = [reg](Context& context, SelectionList sels) { auto set_selections = [reg](Context& context, SelectionList sels) {
auto size = sels.size();
context.selections_write_only() = std::move(sels); context.selections_write_only() = std::move(sels);
context.print_status({format("{} selections from register '{}'", combine ? "Combined" : "Restored", reg), get_face("Information")}); context.print_status({format("{} {} selections from register '{}'",
combine ? "Combined" : "Restored", size, reg),
get_face("Information")});
}; };
if (not combine) if (not combine)