fix(actions): send_to_* and smart_send_to_* now append to history (#2527)
This commit is contained in:
@@ -75,6 +75,12 @@ local actions = setmetatable({}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local append_to_history = function(prompt_bufnr)
|
||||||
|
action_state
|
||||||
|
.get_current_history()
|
||||||
|
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
||||||
|
end
|
||||||
|
|
||||||
--- Move the selection to the next entry
|
--- Move the selection to the next entry
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.move_selection_next = function(prompt_bufnr)
|
actions.move_selection_next = function(prompt_bufnr)
|
||||||
@@ -241,11 +247,7 @@ end
|
|||||||
--- i.e. open the selection in the current buffer
|
--- i.e. open the selection in the current buffer
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_default = {
|
actions.select_default = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "default")
|
return action_set.select(prompt_bufnr, "default")
|
||||||
end,
|
end,
|
||||||
@@ -257,11 +259,7 @@ actions.select_default = {
|
|||||||
--- i.e. open the selection in a new horizontal split
|
--- i.e. open the selection in a new horizontal split
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_horizontal = {
|
actions.select_horizontal = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "horizontal")
|
return action_set.select(prompt_bufnr, "horizontal")
|
||||||
end,
|
end,
|
||||||
@@ -273,11 +271,7 @@ actions.select_horizontal = {
|
|||||||
--- i.e. open the selection in a new vertical split
|
--- i.e. open the selection in a new vertical split
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_vertical = {
|
actions.select_vertical = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "vertical")
|
return action_set.select(prompt_bufnr, "vertical")
|
||||||
end,
|
end,
|
||||||
@@ -289,11 +283,7 @@ actions.select_vertical = {
|
|||||||
--- i.e. open the selection in a new tab
|
--- i.e. open the selection in a new tab
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_tab = {
|
actions.select_tab = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "tab")
|
return action_set.select(prompt_bufnr, "tab")
|
||||||
end,
|
end,
|
||||||
@@ -305,11 +295,7 @@ actions.select_tab = {
|
|||||||
--- i.e. open the selection in a window
|
--- i.e. open the selection in a window
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_drop = {
|
actions.select_drop = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "drop")
|
return action_set.select(prompt_bufnr, "drop")
|
||||||
end,
|
end,
|
||||||
@@ -321,11 +307,7 @@ actions.select_drop = {
|
|||||||
--- i.e. open the selection in a new tab
|
--- i.e. open the selection in a new tab
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_tab_drop = {
|
actions.select_tab_drop = {
|
||||||
pre = function(prompt_bufnr)
|
pre = append_to_history,
|
||||||
action_state
|
|
||||||
.get_current_history()
|
|
||||||
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
|
||||||
end,
|
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "tab drop")
|
return action_set.select(prompt_bufnr, "tab drop")
|
||||||
end,
|
end,
|
||||||
@@ -872,51 +854,68 @@ end
|
|||||||
|
|
||||||
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_selected_to_qflist = function(prompt_bufnr)
|
actions.send_selected_to_qflist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_selected_to_qf(prompt_bufnr, " ")
|
send_selected_to_qf(prompt_bufnr, " ")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_selected_to_qflist = function(prompt_bufnr)
|
actions.add_selected_to_qflist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_selected_to_qf(prompt_bufnr, "a")
|
send_selected_to_qf(prompt_bufnr, "a")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Sends all entries to the quickfix list, replacing the previous entries.
|
--- Sends all entries to the quickfix list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_to_qflist = function(prompt_bufnr)
|
actions.send_to_qflist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_all_to_qf(prompt_bufnr, " ")
|
send_all_to_qf(prompt_bufnr, " ")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Adds all entries to the quickfix list, keeping the previous entries.
|
--- Adds all entries to the quickfix list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_to_qflist = function(prompt_bufnr)
|
actions.add_to_qflist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_all_to_qf(prompt_bufnr, "a")
|
send_all_to_qf(prompt_bufnr, "a")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Sends the selected entries to the location list, replacing the previous entries.
|
--- Sends the selected entries to the location list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_selected_to_loclist = function(prompt_bufnr)
|
actions.send_selected_to_loclist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_selected_to_qf(prompt_bufnr, " ", "loclist")
|
send_selected_to_qf(prompt_bufnr, " ", "loclist")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the location list, keeping the previous entries.
|
--- Adds the selected entries to the location list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_selected_to_loclist = function(prompt_bufnr)
|
actions.add_selected_to_loclist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_selected_to_qf(prompt_bufnr, "a", "loclist")
|
send_selected_to_qf(prompt_bufnr, "a", "loclist")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Sends all entries to the location list, replacing the previous entries.
|
--- Sends all entries to the location list, replacing the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.send_to_loclist = function(prompt_bufnr)
|
actions.send_to_loclist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_all_to_qf(prompt_bufnr, " ", "loclist")
|
send_all_to_qf(prompt_bufnr, " ", "loclist")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Adds all entries to the location list, keeping the previous entries.
|
--- Adds all entries to the location list, keeping the previous entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.add_to_loclist = function(prompt_bufnr)
|
actions.add_to_loclist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
send_all_to_qf(prompt_bufnr, "a", "loclist")
|
send_all_to_qf(prompt_bufnr, "a", "loclist")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
local smart_send = function(prompt_bufnr, mode, target)
|
local smart_send = function(prompt_bufnr, mode, target)
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
@@ -930,31 +929,39 @@ end
|
|||||||
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
--- Sends the selected entries to the quickfix list, replacing the previous entries.
|
||||||
--- If no entry was selected, sends all entries.
|
--- If no entry was selected, sends all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_send_to_qflist = function(prompt_bufnr)
|
actions.smart_send_to_qflist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
smart_send(prompt_bufnr, " ")
|
smart_send(prompt_bufnr, " ")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
--- Adds the selected entries to the quickfix list, keeping the previous entries.
|
||||||
--- If no entry was selected, adds all entries.
|
--- If no entry was selected, adds all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_add_to_qflist = function(prompt_bufnr)
|
actions.smart_add_to_qflist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
smart_send(prompt_bufnr, "a")
|
smart_send(prompt_bufnr, "a")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Sends the selected entries to the location list, replacing the previous entries.
|
--- Sends the selected entries to the location list, replacing the previous entries.
|
||||||
--- If no entry was selected, sends all entries.
|
--- If no entry was selected, sends all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_send_to_loclist = function(prompt_bufnr)
|
actions.smart_send_to_loclist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
smart_send(prompt_bufnr, " ", "loclist")
|
smart_send(prompt_bufnr, " ", "loclist")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Adds the selected entries to the location list, keeping the previous entries.
|
--- Adds the selected entries to the location list, keeping the previous entries.
|
||||||
--- If no entry was selected, adds all entries.
|
--- If no entry was selected, adds all entries.
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.smart_add_to_loclist = function(prompt_bufnr)
|
actions.smart_add_to_loclist = {
|
||||||
|
pre = append_to_history,
|
||||||
|
action = function(prompt_bufnr)
|
||||||
smart_send(prompt_bufnr, "a", "loclist")
|
smart_send(prompt_bufnr, "a", "loclist")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
--- Open completion menu containing the tags which can be used to filter the results in a faster way
|
--- Open completion menu containing the tags which can be used to filter the results in a faster way
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.complete_tag = function(prompt_bufnr)
|
actions.complete_tag = function(prompt_bufnr)
|
||||||
|
|||||||
Reference in New Issue
Block a user