parent
aa92ca96c8
commit
1288a1d385
|
@ -23,9 +23,9 @@ def -params 0..1 \
|
|||
re=$0;
|
||||
sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re);
|
||||
keys=re; gsub(/</, "<lt>", keys); gsub(/\t/, "<c-v><c-i>", keys);
|
||||
out = out " %{" $2 " {MenuInfo}" re "} %{try %{ edit %{" $2 "}; exec %{/\\Q" keys "<ret><c-d>vc} } catch %{ echo %{unable to find tag} } }"
|
||||
out = out " %{" $2 " {MenuInfo}" re "} %{eval -collapse-jumps %{ try %{ edit %{" $2 "}; exec %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }"
|
||||
}
|
||||
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{edit %{" $2 "} %{" $3 "}}" }
|
||||
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{eval -collapse-jumps %{ edit %{" $2 "} %{" $3 "}}}" }
|
||||
END { print length(out) == 0 ? "echo -color Error no such tag " ENVIRON["tagname"] : "menu -markup -auto-single " out }'
|
||||
}}
|
||||
|
||||
|
|
|
@ -1216,7 +1216,8 @@ 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" } } },
|
||||
{ "save-regs", { true, "restore all given registers after execution" } },
|
||||
{ "collapse-jumps", { false, "collapse all jumps into a single one from initial selection" } } },
|
||||
ParameterDesc::Flags::SwitchesOnlyAtStart, 1
|
||||
};
|
||||
|
||||
|
@ -1358,11 +1359,21 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
|
|||
|
||||
Context& c = *real_context;
|
||||
|
||||
const bool collapse_jumps = (bool)parser.get_switch("collapse-jumps");
|
||||
SelectionList jump = c.selections();
|
||||
JumpList original_jump_list = collapse_jumps ? c.jump_list() : JumpList{};
|
||||
|
||||
ScopedSetBool disable_hooks(c.user_hooks_disabled(), no_hooks);
|
||||
ScopedSetBool disable_keymaps(c.keymaps_disabled(), no_keymaps);
|
||||
ScopedSetBool disable_history(c.history_disabled());
|
||||
|
||||
func(parser, c);
|
||||
|
||||
if (collapse_jumps and c.jump_list() != original_jump_list)
|
||||
{
|
||||
c.jump_list() = std::move(original_jump_list);
|
||||
c.jump_list().push(std::move(jump));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,13 @@ struct JumpList
|
|||
const SelectionList& backward(const SelectionList& current);
|
||||
void forget_buffer(Buffer& buffer);
|
||||
|
||||
friend bool operator==(const JumpList& lhs, const JumpList& rhs)
|
||||
{
|
||||
return lhs.m_jumps == rhs.m_jumps and lhs.m_current == rhs.m_current;
|
||||
}
|
||||
|
||||
friend bool operator!=(const JumpList& lhs, const JumpList& rhs) { return not (lhs == rhs); }
|
||||
|
||||
private:
|
||||
using Contents = Vector<SelectionList, MemoryDomain::Selections>;
|
||||
Contents m_jumps;
|
||||
|
|
Loading…
Reference in New Issue
Block a user