From 5a3897572dcf8decfe7b4c9434bc08a69625e4b8 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 18 Jun 2022 02:15:03 -0400 Subject: [PATCH] fixed bug with single word strings in strwrap --- scada-common/util.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scada-common/util.lua b/scada-common/util.lua index 1a36bc0..54a820c 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -83,7 +83,13 @@ function util.strwrap(str, limit) local lines = {} local ln_start = 1 - lines[1] = string.sub(str, 1, str:find("([%-%s]+)") - 1) + local first_break = str:find("([%-%s]+)") + + if first_break ~= nil then + lines[1] = string.sub(str, 1, first_break - 1) + else + lines[1] = str + end ---@diagnostic disable-next-line: discard-returns str:gsub("(%s+)()(%S+)()",