mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -04:00
Fix TSEditQuery with several files (#1191)
- Choice already starts with 1, there isn't need to increment 1 - The first item is the prompt as recommended in `:h inputlist()` (this way the choice matches when using the mouse)
This commit is contained in:
parent
9fb2b0c0b6
commit
2abad14069
1 changed files with 12 additions and 3 deletions
|
|
@ -207,9 +207,18 @@ function M.edit_query_file(query_group, lang)
|
||||||
vim.cmd(':edit '..files[1])
|
vim.cmd(':edit '..files[1])
|
||||||
else
|
else
|
||||||
local counter = 0
|
local counter = 0
|
||||||
local choice = vim.fn.inputlist(vim.tbl_map(function(f) counter = counter + 1;return counter..'. '..f end, files))
|
local choices = {
|
||||||
if choice > 0 then
|
'Select a file:',
|
||||||
vim.cmd(':edit '..files[choice + 1])
|
table.unpack(vim.tbl_map(function(f)
|
||||||
|
counter = counter + 1
|
||||||
|
return counter..'. '..f
|
||||||
|
end,
|
||||||
|
files
|
||||||
|
))
|
||||||
|
}
|
||||||
|
local choice = vim.fn.inputlist(choices)
|
||||||
|
if choice > 0 and choice <= #files then
|
||||||
|
vim.cmd(':edit '..files[choice])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue