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

vim.ui.select telescope: complete hang on focus loss #165

Closed
emmanueltouzery opened this issue Jun 21, 2024 · 1 comment
Closed

vim.ui.select telescope: complete hang on focus loss #165

emmanueltouzery opened this issue Jun 21, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@emmanueltouzery
Copy link
Contributor

emmanueltouzery commented Jun 21, 2024

Describe the bug
when using vim.ui.select with the telescope backend, if you focus out of the telescope window (switch to any another window), telescope will close. However at that point the dressing vim.ui.select implementation is completely hung and no vim.ui.select will open again until neovim is restarted.

System information

  • OS: linux
  • Neovim version: 0.10.0
  • Is this related to a specific vim.ui.select backend? If so, which one? Telescope
  • Dressing config:
    require('dressing').setup({
      input = {
        -- ESC won't close the modal, ability to use vim keys
        insert_only = false,
        get_config = function(opts)
          if opts.kind == 'center_win' then
            return {
              relative = 'editor',
            }
          end
        end
      },
      select = {
        get_config = function(opts)
          -- https://github.com/stevearc/dressing.nvim/issues/22#issuecomment-1067211863
          -- for codeaction, we want null-ls to be last
          -- https://github.com/jose-elias-alvarez/null-ls.nvim/issues/630
          -- for eslint, it's offering me options like "disable eslint rule" which
          -- are almost never what I want, and they appear before the more useful options
          -- from the LSP
          if opts.kind == 'codeaction' then
            return {
              telescope = {
                -- sorter = require'telescope.sorters'.Sorter:new {
                --   scoring_function = function(_, _, line)
                --     local order = tonumber(string.match(line, "^[%d]+"))
                --     if string.find(line, escape_pattern('null-ls')) then
                --       return order+100
                --     else
                --       return order
                --     end
                --   end,
                -- },
                cache_picker = false,
                -- copied from the telescope dropdown theme
                sorting_strategy = "ascending",
                layout_strategy = "center",
                layout_config = {
                  preview_cutoff = 1, -- Preview should always show (unless previewer = false)
                  width = 80,
                  height = 15,
                },
                borderchars = {
                  prompt = { "", "", " ", "", "", "", "", "" },
                  results = { "", "", "", "", "", "", "", "" },
                  preview = { "", "", "", "", "", "", "", "" },
                },
              }
            }
          end
        end,
      },
    })

To Reproduce
Steps to reproduce the behavior:

  1. :lua vim.ui.select({"a", "b"}, {prompt="pick one"}, function(choice) print(choice) end)
  2. escape if you're in insert mode
  3. :1 wincmd w to switch to another window, or any other way to switch to another window than the telescope window. When switching, telescope (dressing) closes
  4. try again => :lua vim.ui.select({"a", "b"}, {prompt="pick one"}, function(choice) print(choice) end)

From now on, vim.ui.select won't open again.

Additional context
I'm pretty certain that the issue is that callback(nil, nil) should be called when telescope is closed, but telescope does not tell us when it gets closed due to focus loss (as opposed for instance of the user explicitly closing telescope). I tried to find a way to get notified somehow when telescope gets closed in such situations, but couldn't do it.

@emmanueltouzery emmanueltouzery added the bug Something isn't working label Jun 21, 2024
@emmanueltouzery
Copy link
Contributor Author

Hmm I realised this is a duplicate of #150

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

2 participants