fix: allow Number type should be allowed for option keys (#1782)

* Number type should be allowed for option keys

Some extension (e.g. `dap`) use integer numbers for their selector
options instead of strings. Before this commit, the interface for these
plugins breaks when using `ui-select` with a stack trace like the
following:

Error detected while processing function StartDebugger:
line   33:
E5108: Error executing lua .../telescope.nvim/lua/telescope/pickers.lua:1359: Should be string, found: number
stack traceback:
        [C]: in function 'assert'
        .../.vim/bundle/telescope.nvim/lua/telescope/pickers.lua:1359: in function 'new'
        ...e-ui-select.nvim/lua/telescope/_extensions/ui-select.lua:22: in function 'pick_one'
        .../nvim-dap/lua/dap/ui.lua:32: in function 'pick_if_many'
        .../nvim-dap/lua/dap.lua:225: in function 'select_config_and_run'
        .../nvim-dap/lua/dap.lua:551: in function 'continue'
        [string ":lua"]:1: in main chunk

* style

Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
This commit is contained in:
Fabio Manganiello
2022-03-11 12:49:55 +01:00
committed by GitHub
parent 1c4cd6cdaa
commit c5bf83dc61

View File

@@ -1359,7 +1359,7 @@ pickers.new = function(opts, defaults)
local result = {}
for k, v in pairs(opts) do
assert(type(k) == "string", "Should be string, opts")
assert(type(k) == "string" or type(k) == "number", "Should be string or number, found: " .. type(k))
result[k] = v
end