diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-07-09 20:45:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-09 20:45:29 +0200 |
| commit | 36996056272a7174868367acf1043cead333d115 (patch) | |
| tree | cd5a33dac60c9c5ee6ae17b6be2f51fa44b52562 /lua/telescope/actions/state.lua | |
| parent | 385020eb232b48a5a3583f531ff27266fb06eec4 (diff) | |
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 :)
Diffstat (limited to 'lua/telescope/actions/state.lua')
| -rw-r--r-- | lua/telescope/actions/state.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lua/telescope/actions/state.lua b/lua/telescope/actions/state.lua index 7ef9f6c..8470f2d 100644 --- a/lua/telescope/actions/state.lua +++ b/lua/telescope/actions/state.lua @@ -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 |
