fix(picker): set `current_line` state earlier
Sets the current_line global state earlier in the event loop rather than in get_results_completor. This makes it safer to access current_line earlier (eg. for building an entry).
closes #3051
I'm not super confident this is safe to do without some unintended side effects. I've experienced some finicky race conditions with the picker:_get_prompt before so I'll use this branch for a bit.
Thanks for the quick patch! I'll run this branch in my config as well.
I haven't come across any issues myself but I wanna double check with @Conni2461 before merging this. Maybe there's some good reason not obvious to me for why we previously set current_line pretty late in our picker event loop.
I've been running this branch for a month now with no issues. Is there anything I can do to help get it merged?
For some more context, I'm using this feature to implement a limited depth file tree browser that switches to default paths when you start typing.
https://github.com/nvim-telescope/telescope.nvim/assets/29129/e2eb2f71-6af5-4995-9a58-c19b7b6fe003
extensions = {
file_browser = {
path_display = function(opts, path)
local action_state = require("telescope.actions.state")
local current_line = action_state.get_current_line()
if current_line == "" and opts.finder.files and path:match("%w+/%w+") then
return path:gsub("^.+/", " ")
else
return path
end
end,
wrap_results = false,
depth = 2,
},
}
ok let's merge this then before I forget about it.