From a8d81e395b9ebfff7250f0d491520ed7c1a29543 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 27 Nov 2015 13:57:46 +0000 Subject: [PATCH] Support dropping last jump and use it to fix :tag double jump push Fixes #492 --- rc/ctags.kak | 2 +- src/context.cc | 7 +++++++ src/context.hh | 1 + src/normal.cc | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rc/ctags.kak b/rc/ctags.kak index af9bfc39..db2de2e9 100644 --- a/rc/ctags.kak +++ b/rc/ctags.kak @@ -23,7 +23,7 @@ def -shell-params \ re=$0; sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re); keys=re; gsub(/", keys); gsub(/\t/, "", keys); - out = out " %{" $2 " {MenuInfo}" re "} %{try %{ edit %{" $2 "}; exec %{/\\Q" keys "vc} } catch %{ echo %{unable to find tag} } }" + out = out " %{" $2 " {MenuInfo}" re "} %{try %{ edit %{" $2 "}; exec %{/\\Q" keys "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 }' diff --git a/src/context.cc b/src/context.cc index e3eed5b1..48a502e1 100644 --- a/src/context.cc +++ b/src/context.cc @@ -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 diff --git a/src/context.hh b/src/context.hh index 3900d1d8..af184663 100644 --- a/src/context.hh +++ b/src/context.hh @@ -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); diff --git a/src/normal.cc b/src/normal.cc index 54b062c1..24f5e1c9 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -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 }, { ctrl('o'), "jump backward in jump list", jump }, { 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 },