folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.11k stars 173 forks source link

fix: use (lnum, 0) for telescope item without col #524

Closed FeiyouG closed 4 days ago

FeiyouG commented 5 days ago

When sending telescope result to trouble, if there is no col field in the item (e.g. telescope builtin.current_buffer_fuzzy_find), the operation will fail with the following error:

E5108: Error executing lua: ...m/plugins/trouble.nvim/lua/trouble/sources/telescope.lua:55: bad argument #1 to 'sub' (number expected, got nil)
stack traceback:
        [C]: in function 'sub'
        ...m/plugins/trouble.nvim/lua/trouble/sources/telescope.lua:55: in function 'item'
        ...m/plugins/trouble.nvim/lua/trouble/sources/telescope.lua:99: in function 'add'
        ...m/plugins/trouble.nvim/lua/trouble/sources/telescope.lua:120: in function 'key_func'
        ...e/nvim/plugins/telescope.nvim/lua/telescope/mappings.lua:293: in function <...e/nvim/plugins/telescope.nvim/lua/telescope/mappings.lua:292>

This PR will make trouble gracefully accept items from telescope that doesn't have col field by setting word = nil and pos = {lnum, 0}.

folke commented 4 days ago

Thanks!