feat: cycle prompt history (#521)
history is enabled on default but cycle_history_next and cycle_history_prev is not mapped yet
Example:
require('telescope').setup {
defaults = {
mappings = {
i = {
["<C-Down>"] = require('telescope.actions').cycle_history_next,
["<C-Up>"] = require('telescope.actions').cycle_history_prev,
}
}
}
}
For more information :help telescope.defaults.history
big thanks to clason and all other testers :)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
---@brief ]]
|
||||
|
||||
local global_state = require('telescope.state')
|
||||
local conf = require('telescope.config').values
|
||||
|
||||
local action_state = {}
|
||||
|
||||
@@ -36,4 +37,19 @@ function action_state.select_key_to_edit_key(type)
|
||||
return select_to_edit_map[type]
|
||||
end
|
||||
|
||||
function action_state.get_current_history()
|
||||
local history = global_state.get_global_key("history")
|
||||
if not history then
|
||||
if not conf.history or type(conf.history) ~= "table" then
|
||||
history = require('telescope.actions.history').get_simple_history()
|
||||
global_state.set_global_key("history", history)
|
||||
else
|
||||
history = conf.history.handler()
|
||||
global_state.set_global_key("history", history)
|
||||
end
|
||||
end
|
||||
|
||||
return history
|
||||
end
|
||||
|
||||
return action_state
|
||||
|
||||
Reference in New Issue
Block a user