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

Race with concurrent selections in telescope and builtin backends #139

Closed
AlexJF opened this issue Jan 19, 2024 · 1 comment
Closed

Race with concurrent selections in telescope and builtin backends #139

AlexJF opened this issue Jan 19, 2024 · 1 comment
Assignees
Labels
bug Something isn't working P0 Highest priority, will receive attention

Comments

@AlexJF
Copy link
Contributor

AlexJF commented Jan 19, 2024

Describe the bug
Some situations may lead to multiple selection prompts happening concurrently. For instance when using the vtsls LSP and opening a typescript project we get these 2 prompts at startup:

image

image

These show up as expected when using the nui backend but when using the default telescope backend, only one of them will show up. The LSP will continue showing as loading until it eventually times out on the selection.

When using the builtin backend, an error shows up "window was closed immediately" and the selection seems to get immediately cancelled. A single select UI still shows up but selecting it seems to not have any effect.

System information

  • OS: [mac]

  • Neovim version:

    NVIM v0.9.5
    Build type: Release
    LuaJIT 2.1.1703358377
    
  • Is this related to a specific vim.ui.select backend? If so, which one? telescope and builtin

  • Dressing config:

return {
  "stevearc/dressing.nvim",
  -- dir = "~/Projects/dressing.nvim",
  enabled = true,
  opts = {
    select = {
      enabled = true,
      -- default telescope backend seems to not support "concurrent" selections
      backend = { "nui" },
      nui = {
        min_height = 0,
      },
    },
    input = {
      -- Allow escaping to normal mode inside inputs
      insert_only = false,
    },
  },
}

To Reproduce
Steps to reproduce the behavior:

  1. We can easily reproduce this behaviour using the select test file in tests/manual/select.lua by adding a second run test call:
-- Run this test with :source %

local function run_test(backend)
  local config = require("dressing.config")
  local prev_backend = config.select.backend
  config.select.backend = backend
  vim.ui.select({ "first", "second", "third" }, {
    prompt = "Make selection: ",
    kind = "test",
  }, function(item, lnum)
    if item and lnum then
      vim.notify(string.format("selected '%s' (idx %d)", item, lnum), vim.log.levels.INFO)
    else
      vim.notify("Selection canceled", vim.log.levels.INFO)
    end
    config.select.backend = prev_backend
  end)
end

-- Replace this with the desired backend to test
run_test("telescope")
run_test("telescope")

Screenshots

dressing

This is the behaviour without dressing.nvim btw:

dressing2

@AlexJF AlexJF added the bug Something isn't working label Jan 19, 2024
@AlexJF AlexJF changed the title Race condition with concurrent selections in default telescope and builtin backends Race condition with concurrent selections in telescope and builtin backends Jan 19, 2024
@AlexJF AlexJF changed the title Race condition with concurrent selections in telescope and builtin backends Race with concurrent selections in telescope and builtin backends Jan 19, 2024
@stevearc stevearc added the P0 Highest priority, will receive attention label Jan 21, 2024
@stevearc
Copy link
Owner

Fixed for all backends and for vim.ui.input as well

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

No branches or pull requests

2 participants