From f419acf9f9eb72b0c742d2db832ab6f2956ebadc Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Tue, 31 Oct 2023 11:12:56 -0600 Subject: [PATCH] improve error checking --- lua/scratch/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/scratch/init.lua b/lua/scratch/init.lua index 2fc94d3..dd495bf 100644 --- a/lua/scratch/init.lua +++ b/lua/scratch/init.lua @@ -58,7 +58,7 @@ end -- local function create_new_scratch_buffer(new_window, buffer_name) -- Check if the buffer name is set - if not buffer_name or type(buffer_name) ~= "string" then + if not buffer_name or type(buffer_name) ~= "string" or string.len(buffer_name) == 0 then error("Buffer name not set or invalid in create_new_scratch_buffer") return end @@ -151,7 +151,9 @@ function M.setup(opts) -- Check for configuration overrides passed in via opts if opts ~= nil and type(opts) == "table" then - if opts.buffer_name and type(opts.buffer_name) ~= "string" then + if + opts.buffer_name and (type(opts.buffer_name) ~= "string" or string.len(opts.buffer_name) == 0) + then error("Invalid buffer name provided in setup options") return end