diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-02-24 19:02:15 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-02-24 19:02:15 +1100 |
| commit | 4d11bb20c342ae4a2c2903a8faf8786e39ae2eec (patch) | |
| tree | d8a888a79466f06db9905f58db97b8300f82f027 /src | |
| parent | 933ac4d3d598e95e99e72e0f6258e40699548712 (diff) | |
Always collapse jumps in exec/eval, remove -collapse-jumps switch
There does not seem to be any reasonable use cases of not collapsing
jumps when the input is not comming from the user. Always collapse
them.
It could make sense to move jump collapsing out of context_wrap as
in general any action not comming directly from the user should
collapse them, at the moment a comment or mapping will not collapse
jumps, which is unfortunate.
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/commands.cc b/src/commands.cc index 66696202..a0b75ef2 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1522,8 +1522,7 @@ const ParameterDesc context_wrap_params = { { "no-hooks", { false, "disable hooks" } }, { "with-maps", { false, "use user defined key mapping when executing keys" } }, { "itersel", { false, "run once for each selection with that selection as the only one" } }, - { "save-regs", { true, "restore all given registers after execution (defaults to '/\"|^@')" } }, - { "collapse-jumps", { false, "collapse all jumps into a single one from initial selection" } } }, + { "save-regs", { true, "restore all given registers after execution (defaults to '/\"|^@')" } } }, ParameterDesc::Flags::SwitchesOnlyAtStart, 1 }; @@ -1675,17 +1674,17 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) } else { - Optional<JumpList> original_jump_list; - if (not draft and (bool)parser.get_switch("collapse-jumps")) - original_jump_list = c.jump_list(); + auto original_jump_list = draft ? Optional<JumpList>{} : c.jump_list(); + auto jump = draft ? Optional<SelectionList>{} : c.selections(); - SelectionList jump = c.selections(); func(parser, c); - if (original_jump_list and c.jump_list() != *original_jump_list) + // If the jump list got mutated, collapse all jumps into a single one from original selections + if (not draft and c.jump_list() != *original_jump_list) { - c.jump_list() = std::move(*original_jump_list); - c.jump_list().push(std::move(jump)); + original_jump_list->push(std::move(*jump)); + if (c.jump_list() != *original_jump_list) + c.jump_list() = std::move(*original_jump_list); } } } |
