actions.state.get_current_line() is incorrect inside path_display function
schoblaska opened this issue · 0 comments
schoblaska commented
Description
Inside of a path_display
function, actions.state.get_current_line()
returns the previous state of the prompt input rather than the current state.
Neovim version
NVIM v0.10.0-dev-2799+ge016f5bee-Homebrew
Build type: Release
LuaJIT 2.1.1710088188
Run "nvim -V1 -v" for more info
Operating system and version
macOS 14.4.1
Telescope version / branch / rev
telescope head
checkhealth telescope
telescope: health#telescope#check
Checking for required plugins
- OK plenary installed.
- WARNING nvim-treesitter not found. (Required for `:Telescope treesitter`.)
Checking external dependencies
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.2.1
===== Installed extensions =====
Telescope Extension: `fzf`
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured
Steps to reproduce
nvim -nu minimal.lua
:Telescope find_files
- Type in prompt and look at the results list
Expected behavior
I would expect get_current_line()
to return what's currently in the prompt input.
Actual behavior
Screen.Recording.2024-04-14.at.6.14.58.PM.mov
Minimal config
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
require("packer").startup {
{
"wbthomason/packer.nvim",
{
"nvim-telescope/telescope.nvim",
requires = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", run = "make" },
},
},
-- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
},
config = {
package_root = package_root,
compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true },
},
}
end
_G.load_config = function()
require("telescope").setup {
pickers = {
find_files = {
path_display = function(opts, path)
local action_state = require "telescope.actions.state"
local current_line = action_state.get_current_line()
return "(" .. current_line .. "): " .. path
end,
},
},
}
require("telescope").load_extension "fzf"
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
print "Installing Telescope and dependencies."
vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]