telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

fix(picker): set `current_line` state earlier

Open jamestrew opened this issue 1 year ago • 2 comments

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.

jamestrew avatar Apr 15 '24 00:04 jamestrew

Thanks for the quick patch! I'll run this branch in my config as well.

schoblaska avatar Apr 15 '24 01:04 schoblaska

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.

jamestrew avatar Apr 20 '24 04:04 jamestrew

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,
  },
}

schoblaska avatar May 16 '24 00:05 schoblaska

ok let's merge this then before I forget about it.

jamestrew avatar May 16 '24 01:05 jamestrew