Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All pickers do not populate the results table hence delete_selection fails #3384

Open
sswastik02 opened this issue Dec 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sswastik02
Copy link

Description

Pickers that utilize async_oneshot_finder populate the results table, while those using async_job_finder do not. This behavior difference causes issues when relying on results for certain picker operations. Below is the code responsible for finders that populate the results table:

For example, the live_grep picker uses async_job_finder, resulting in self.finder.results being nil. Consequently, operations like the delete_selection function fail with such pickers because it relies on self.finder.results, as seen in the following code:

for result_index, result_entry in pairs(self.finder.results) do

Neovim version

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068

Operating system and version

Debian 13

Telescope version / branch / rev

telescope 0.1.8

checkhealth telescope

telescope: health#telescope#check

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 14.1.1
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

===== Installed extensions ===== ~

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Steps to reproduce

  1. Open find_files, make a meaningful search then press <C-r>
  2. Open live_grep, make a meaningful search then press <C-r>

Expected behavior

The function should automatically remove the entry from the search results in both cases (live_grep and find_files)

Actual behavior

find_files search results gets removed on using <C-r>, however when performing same operation on live_grep, the following error is encountered

E5108: Error executing lua: .../.repro/plugins/telescope.nvim/lua/telescope/pic
kers.lua:831: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
        [C]: in function 'pairs'
        .../.repro/plugins/telescope.nvim/lua/telescope/pickers.lua:831: in function 'delete_selection'
        /home/USER/.config/nvim/minimal.lua:37: in function 'key_func'
        ....repro/plugins/telescope.nvim/lua/telescope/mappings.lua:293: in function <....repro/plugins/telescope.nvim/lua/telescope/mappings.lua:292>

Minimal config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
    config = function()
      -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
      local action_state = require("telescope.actions.state")
      require("telescope").setup {
        defaults = {
          mappings = {
            i = {
              ["<C-r>"] = function(prompt_bufnr)
                local current_picker = action_state.get_current_picker(prompt_bufnr)
                current_picker:delete_selection(function() return true end)
              end
            },
          },
        }
      }
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
@sswastik02 sswastik02 added the bug Something isn't working label Dec 8, 2024
@sswastik02
Copy link
Author

I’d be happy to help resolve this issue if it’s not already being addressed. Please let me know how I can contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant