improve error checking

This commit is contained in:
swaits committed 2023-10-31 11:12:56 -06:00
1 parent b8dfde353a
commit f419acf9f9
1 file changed
+4 -2
+4 -2
View File
@@ -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