Keep prompt when switching find file and buffer
This commit is contained in:
parent
75e56fead9
commit
07322e2636
@ -21,16 +21,27 @@ spec.config = function()
|
||||
local builtin = require("telescope.builtin")
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
local cycle_picker = function(bufnr)
|
||||
local function get_current_prompt(picker)
|
||||
local win = picker.prompt_win
|
||||
local bufnr = picker.prompt_bufnr
|
||||
local prefix = picker.prompt_prefix
|
||||
local lines = vim.api.nvim_win_get_cursor(win)
|
||||
local line_start = lines[1] - 1
|
||||
local line_end = line_start + 1
|
||||
local buf_line = vim.api.nvim_buf_get_lines(bufnr, line_start, line_end, false)[1]
|
||||
return buf_line:sub(#prefix + 1)
|
||||
end
|
||||
|
||||
local function cycle_picker(bufnr)
|
||||
local state = require("telescope.actions.state")
|
||||
local current_picker = state.get_current_picker(bufnr)
|
||||
|
||||
local title = current_picker.prompt_title
|
||||
local current_prompt = get_current_prompt(current_picker)
|
||||
|
||||
if title == "Buffers" then
|
||||
builtin.find_files()
|
||||
builtin.find_files({ default_text = current_prompt })
|
||||
elseif title == "Find Files" then
|
||||
builtin.buffers()
|
||||
builtin.buffers({ default_text = current_prompt })
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user