nvim-telescope / telescope-ui-select.nvim

MIT License
774 stars 18 forks source link

Fix bug where filtering items is returning wrong index #4

Closed JafarAbdi closed 2 years ago

JafarAbdi commented 2 years ago

This PR should fix a bug where filtering the options is returning the wrong index (text and index doesn't correspond to each other), here's a simple reproducible example

local options = { "AD", "AB", "AC", "CC", "BB" }
vim.ui.select(options, { prompt = "Select Command: " }, function(command, index)
  print(string.format("command: %s - index: %s - command_index: %s", command, index, options[index]))
end)

These two gifs show the bug & fix

bug

fix

tjdevries commented 2 years ago

Thanks :) good find!