Skip to content

Commit

Permalink
fix(actions): send_to_* and smart_send_to_* now append to history (#2527
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Conni2461 committed May 24, 2023
1 parent 5b7cedd commit dda9a39
Showing 1 changed file with 84 additions and 77 deletions.
161 changes: 84 additions & 77 deletions lua/telescope/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ local actions = setmetatable({}, {
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
---@param prompt_bufnr number: The prompt bufnr
actions.move_selection_next = function(prompt_bufnr)
Expand Down Expand Up @@ -241,11 +247,7 @@ end
--- i.e. open the selection in the current buffer
---@param prompt_bufnr number: The prompt bufnr
actions.select_default = {
pre = function(prompt_bufnr)
action_state
.get_current_history()
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
end,
pre = append_to_history,
action = function(prompt_bufnr)
return action_set.select(prompt_bufnr, "default")
end,
Expand All @@ -257,11 +259,7 @@ actions.select_default = {
--- i.e. open the selection in a new horizontal split
---@param prompt_bufnr number: The prompt bufnr
actions.select_horizontal = {
pre = function(prompt_bufnr)
action_state
.get_current_history()
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
end,
pre = append_to_history,
action = function(prompt_bufnr)
return action_set.select(prompt_bufnr, "horizontal")
end,
Expand All @@ -273,11 +271,7 @@ actions.select_horizontal = {
--- i.e. open the selection in a new vertical split
---@param prompt_bufnr number: The prompt bufnr
actions.select_vertical = {
pre = function(prompt_bufnr)
action_state
.get_current_history()
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
end,
pre = append_to_history,
action = function(prompt_bufnr)
return action_set.select(prompt_bufnr, "vertical")
end,
Expand All @@ -289,11 +283,7 @@ actions.select_vertical = {
--- i.e. open the selection in a new tab
---@param prompt_bufnr number: The prompt bufnr
actions.select_tab = {
pre = function(prompt_bufnr)
action_state
.get_current_history()
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
end,
pre = append_to_history,
action = function(prompt_bufnr)
return action_set.select(prompt_bufnr, "tab")
end,
Expand All @@ -305,11 +295,7 @@ actions.select_tab = {
--- i.e. open the selection in a window
---@param prompt_bufnr number: The prompt bufnr
actions.select_drop = {
pre = function(prompt_bufnr)
action_state
.get_current_history()
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
end,
pre = append_to_history,
action = function(prompt_bufnr)
return action_set.select(prompt_bufnr, "drop")
end,
Expand All @@ -321,11 +307,7 @@ actions.select_drop = {
--- i.e. open the selection in a new tab
---@param prompt_bufnr number: The prompt bufnr
actions.select_tab_drop = {
pre = function(prompt_bufnr)
action_state
.get_current_history()
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
end,
pre = append_to_history,
action = function(prompt_bufnr)
return action_set.select(prompt_bufnr, "tab drop")
end,
Expand Down Expand Up @@ -872,51 +854,68 @@ end

--- Sends the selected entries to the quickfix list, replacing the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.send_selected_to_qflist = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, " ")
end

actions.send_selected_to_qflist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, " ")
end,
}
--- Adds the selected entries to the quickfix list, keeping the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.add_selected_to_qflist = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, "a")
end

actions.add_selected_to_qflist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, "a")
end,
}
--- Sends all entries to the quickfix list, replacing the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.send_to_qflist = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, " ")
end

actions.send_to_qflist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, " ")
end,
}
--- Adds all entries to the quickfix list, keeping the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.add_to_qflist = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, "a")
end

actions.add_to_qflist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, "a")
end,
}
--- Sends the selected entries to the location list, replacing the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.send_selected_to_loclist = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, " ", "loclist")
end

actions.send_selected_to_loclist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, " ", "loclist")
end,
}
--- Adds the selected entries to the location list, keeping the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.add_selected_to_loclist = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, "a", "loclist")
end

actions.add_selected_to_loclist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_selected_to_qf(prompt_bufnr, "a", "loclist")
end,
}
--- Sends all entries to the location list, replacing the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.send_to_loclist = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, " ", "loclist")
end

actions.send_to_loclist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, " ", "loclist")
end,
}
--- Adds all entries to the location list, keeping the previous entries.
---@param prompt_bufnr number: The prompt bufnr
actions.add_to_loclist = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, "a", "loclist")
end
actions.add_to_loclist = {
pre = append_to_history,
action = function(prompt_bufnr)
send_all_to_qf(prompt_bufnr, "a", "loclist")
end,
}

local smart_send = function(prompt_bufnr, mode, target)
local picker = action_state.get_current_picker(prompt_bufnr)
Expand All @@ -930,31 +929,39 @@ end
--- Sends the selected entries to the quickfix list, replacing the previous entries.
--- If no entry was selected, sends all entries.
---@param prompt_bufnr number: The prompt bufnr
actions.smart_send_to_qflist = function(prompt_bufnr)
smart_send(prompt_bufnr, " ")
end

actions.smart_send_to_qflist = {
pre = append_to_history,
action = function(prompt_bufnr)
smart_send(prompt_bufnr, " ")
end,
}
--- Adds the selected entries to the quickfix list, keeping the previous entries.
--- If no entry was selected, adds all entries.
---@param prompt_bufnr number: The prompt bufnr
actions.smart_add_to_qflist = function(prompt_bufnr)
smart_send(prompt_bufnr, "a")
end

actions.smart_add_to_qflist = {
pre = append_to_history,
action = function(prompt_bufnr)
smart_send(prompt_bufnr, "a")
end,
}
--- Sends the selected entries to the location list, replacing the previous entries.
--- If no entry was selected, sends all entries.
---@param prompt_bufnr number: The prompt bufnr
actions.smart_send_to_loclist = function(prompt_bufnr)
smart_send(prompt_bufnr, " ", "loclist")
end

actions.smart_send_to_loclist = {
pre = append_to_history,
action = function(prompt_bufnr)
smart_send(prompt_bufnr, " ", "loclist")
end,
}
--- Adds the selected entries to the location list, keeping the previous entries.
--- If no entry was selected, adds all entries.
---@param prompt_bufnr number: The prompt bufnr
actions.smart_add_to_loclist = function(prompt_bufnr)
smart_send(prompt_bufnr, "a", "loclist")
end

actions.smart_add_to_loclist = {
pre = append_to_history,
action = function(prompt_bufnr)
smart_send(prompt_bufnr, "a", "loclist")
end,
}
--- 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
actions.complete_tag = function(prompt_bufnr)
Expand Down

0 comments on commit dda9a39

Please sign in to comment.