summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/state.lua
blob: 7ef9f6c7e92afe1b1de6445ea4ca574092a8e300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---@tag telescope.actions.state

---@brief [[
--- Functions to be used to determine the current state of telescope.
---
--- Generally used from within other |telescope.actions|
---@brief ]]

local global_state = require('telescope.state')

local action_state = {}

--- Get the current entry
function action_state.get_selected_entry()
  return global_state.get_global_key('selected_entry')
end

--- Gets the current line
function action_state.get_current_line()
  return global_state.get_global_key('current_line')
end

--- Gets the current picker
---@param prompt_bufnr number: The prompt bufnr
function action_state.get_current_picker(prompt_bufnr)
  return global_state.get_status(prompt_bufnr).picker
end

local select_to_edit_map = {
  default = "edit",
  horizontal = "new",
  vertical = "vnew",
  tab = "tabedit",
}
function action_state.select_key_to_edit_key(type)
  return select_to_edit_map[type]
end

return action_state