Skip to content

Commit 499e074

Browse files
authored
fix(filtetype.lua): don't fail on integer filepath (#498)
This looks to be very similar to #465 I have been encountering the below error when the filepath is an integer. ``` Error executing vim.schedule lua callback: ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: Error executing lua: ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:123: attempt to index local 'filepath' (a number value) stack traceback: ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:123: in function 'detect_from_name' ...al/share/nvim/lazy/plenary.nvim/lua/plenary/filetype.lua:167: in function 'detect' ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:434: in function <...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428> [C]: in function 'nvim_buf_call' ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: in function <...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:422> stack traceback: [C]: in function 'nvim_buf_call' ...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:428: in function <...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:422> ```
1 parent 5254482 commit 499e074

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lua/plenary/filetype.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ filetype.detect = function(filepath, opts)
160160
opts = opts or {}
161161
opts.fs_access = opts.fs_access or true
162162

163+
if type(filepath) ~= string then
164+
filepath = tostring(filepath)
165+
end
166+
163167
local match = filetype.detect_from_name(filepath)
164168
if match ~= "" then
165169
return match

0 commit comments

Comments
 (0)