From 69e8715786d1ee86249eff326f9d6804ee388502 Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Fri, 9 Jun 2023 18:51:17 +0200 Subject: [PATCH] fix(previewer): only run ftdetect for files (#2559) --- lua/telescope/previewers/utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/telescope/previewers/utils.lua b/lua/telescope/previewers/utils.lua index e325a6d..3aa5d9b 100644 --- a/lua/telescope/previewers/utils.lua +++ b/lua/telescope/previewers/utils.lua @@ -10,7 +10,7 @@ local utils = {} local detect_from_shebang = function(p) local s = p:readbyterange(0, 256) - if not s then + if s then local lines = vim.split(s, "\n") return vim.filetype.match { contents = lines } end @@ -40,7 +40,7 @@ utils.filetype_detect = function(filepath) end local p = Path:new(filepath) - if p and p:exists() then + if p and p:is_file() then match = detect_from_shebang(p) if match and match ~= "" then return match