From 3db881db81b66773baab510ebc18271a05a69372 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 19 Nov 2024 12:05:21 +0100 Subject: [PATCH] fix(util): error when filetype is nil --- lua/copilot/util.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/copilot/util.lua b/lua/copilot/util.lua index 7dbc1b0f..efa3b3b2 100644 --- a/lua/copilot/util.lua +++ b/lua/copilot/util.lua @@ -139,10 +139,10 @@ local language_normalization_map = { } function M.language_for_file_type(filetype) - -- trim filetypes after dot, e.g. `yaml.gotexttmpl` -> `yaml` - local ft = string.gsub(filetype, "%..*", "") - if not ft or ft == "" then - ft = "text" + local ft = "text" + if filetype then + -- trim filetypes after dot, e.g. `yaml.gotexttmpl` -> `yaml` + ft = string.gsub(filetype, "%..*", "") or "text" end return language_normalization_map[ft] or ft end