changeset 628:1e6287df57f5

abort filetypo when there are no matches
author zegervdv <zegervdv@me.com>
date Thu, 04 Aug 2022 22:39:11 +0200
parents a2a5862a3bd3
children af14855ab067
files dot_config/nvim/plugin/filetypo.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dot_config/nvim/plugin/filetypo.lua	Thu Jul 28 22:25:29 2022 +0200
+++ b/dot_config/nvim/plugin/filetypo.lua	Thu Aug 04 22:39:11 2022 +0200
@@ -5,7 +5,11 @@
 
   local filename = vim.fn.expand '%'
   local matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 0), '\n')
-  if matching_files == nil then matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 1), '\n') end
+  if matching_files == nil or vim.tbl_isempty(matching_files) then
+    matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 1), '\n')
+  end
+
+  if matching_files == nil or vim.tbl_isempty(matching_files) then return end
 
   local buf = vim.api.nvim_get_current_buf()
   vim.schedule(function()