Support dropping last jump and use it to fix :tag double jump push

Fixes #492
This commit is contained in:
Maxime Coste 2015-11-27 13:57:46 +00:00
parent 516e999a28
commit a8d81e395b
4 changed files with 16 additions and 1 deletions

View File

@ -23,7 +23,7 @@ def -shell-params \
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>vc} } catch %{ echo %{unable to find tag} } }"
out = out " %{" $2 " {MenuInfo}" re "} %{try %{ edit %{" $2 "}; exec %{/\\Q" keys "<ret><c-d>vc} } catch %{ echo %{unable to find tag} } }"
}
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{edit %{" $2 "} %{" $3 "}}" }
END { print length(out) == 0 ? "echo -color Error no such tag " ENVIRON["tagname"] : "menu -markup -auto-single " out }'

View File

@ -99,6 +99,13 @@ void Context::push_jump()
m_current_jump = m_jump_list.end();
}
void Context::drop_jump()
{
if (not m_jump_list.empty())
m_jump_list.pop_back();
m_current_jump = m_jump_list.end();
}
const SelectionList& Context::jump_forward()
{
if (m_current_jump != m_jump_list.end() and

View File

@ -114,6 +114,7 @@ public:
StringView main_sel_register_value(StringView reg) const;
void push_jump();
void drop_jump();
const SelectionList& jump_forward();
const SelectionList& jump_backward();
void forget_jumps_to_buffer(Buffer& buffer);

View File

@ -1151,6 +1151,12 @@ void push_selections(Context& context, NormalParams)
get_face("Information") });
}
void drop_jump(Context& context, NormalParams)
{
context.drop_jump();
context.print_status({ "dropped last jump", get_face("Information") });
}
void align(Context& context, NormalParams)
{
auto& selections = context.selections();
@ -1629,6 +1635,7 @@ static NormalCmdDesc cmds[] =
{ ctrl('i'), "jump forward in jump list",jump<Forward> },
{ ctrl('o'), "jump backward in jump list", jump<Backward> },
{ ctrl('s'), "push current selections in jump list", push_selections },
{ ctrl('d'), "drop last jump from jump list", drop_jump },
{ '\'', "rotate main selection", rotate_selections },
{ alt('\''), "rotate selections content", rotate_selections_content },