Bugfix in terminal.lua

terminal.read() used to crash if no options were provided.
This commit is contained in:
WahPlus
2025-11-01 08:42:04 +02:00
parent f5fcc84903
commit d24e00c308
+4 -3
View File
@@ -257,15 +257,16 @@ function module.init()
function _G._PUBLIC.terminal.read(options)
checkArg(1, options, "table", "nil")
local function checkOption(name, value, neededType)
assert(type(value) == "string" or not value, ("%s option must be %s, %s provided"):format(name, neededType, type(value)))
assert(not value or type(value) == neededType, ("%s option must be %s, %s provided"):format(name, neededType, type(value)))
end
if not options then
options = {}
end
if options then
checkOption("readHistoryType", options.readHistoryType, "string")
checkOption("prefix", options.prefix, "string")
checkOption("maxChars", options.maxChars, "number")
checkOption("defaultText", options.defaultText, "string")
checkOption("censor", options.censor, "string")
end
options.maxChars = options.maxChars or math.huge