From 2366af29e2472243227b2d8cbfdbe1ab173ad9c4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 12 Jan 2018 07:50:52 +1100 Subject: [PATCH] Slight refactor of jump collapsing code --- src/commands.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index c86cc15c..330f45fb 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1655,15 +1655,16 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) } else { - const bool collapse_jumps = not draft and (bool)parser.get_switch("collapse-jumps"); - SelectionList jump = c.selections(); - JumpList original_jump_list = collapse_jumps ? c.jump_list() : JumpList{}; + Optional original_jump_list; + if (not draft and (bool)parser.get_switch("collapse-jumps")) + original_jump_list = c.jump_list(); + SelectionList jump = c.selections(); func(parser, c); - if (collapse_jumps and c.jump_list() != original_jump_list) + if (original_jump_list and c.jump_list() != *original_jump_list) { - c.jump_list() = std::move(original_jump_list); + c.jump_list() = std::move(*original_jump_list); c.jump_list().push(std::move(jump)); } }