fix(previewer): improve binary mime type check (#3083)
* fix(previewer): improve binary mime type check Problem: mime type for a ts/js file can either return `text/plain` or `application/javascript` based on the contents of the file. Previously, this meant `application/javascript` would be considered "possibly binary". This, in conjunction with how `vim.filetype.match` does not give a result for a filename that ends in `.ts`, would lead to a typescript file taking the path of `check_mime_type` and eventually `mime_hook`. Solution: Include `application/javascript` as a non-binary file type during mime type check. * [docgen] Update doc/telescope.txt skip-checks: true --------- Co-authored-by: Github Actions <actions@github>
This commit is contained in:
@@ -168,9 +168,8 @@ local handle_file_preview = function(filepath, bufnr, stat, opts)
|
||||
end
|
||||
if opts.preview.check_mime_type == true and has_file and (opts.ft == nil or opts.ft == "") then
|
||||
-- avoid SIGABRT in buffer previewer happening with utils.get_os_command_output
|
||||
local output = capture(string.format([[file --mime-type -b "%s"]], filepath))
|
||||
local mime_type = vim.split(output, "/")
|
||||
if mime_type[1] ~= "text" and mime_type[1] ~= "inode" and mime_type[2] ~= "json" then
|
||||
local mime_type = capture(string.format([[file --mime-type -b "%s"]], filepath))
|
||||
if putils.binary_mime_type(mime_type) then
|
||||
if type(opts.preview.mime_hook) == "function" then
|
||||
opts.preview.mime_hook(filepath, bufnr, opts)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user