From 75161d44913829ab9fa526e705574005348b32df Mon Sep 17 00:00:00 2001 From: duncathan Date: Tue, 11 Jan 2022 22:34:39 -0600 Subject: [PATCH] actually i was wrong; i was just handling length wrong --- caver/tsc_file.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/caver/tsc_file.lua b/caver/tsc_file.lua index 95e65c0..adc8fa0 100644 --- a/caver/tsc_file.lua +++ b/caver/tsc_file.lua @@ -34,7 +34,7 @@ function TscFile:_stringReplace(text, needle, replacement, label, overrides) local i, o = -1, -1 while(o <= i) do o = nil - i = text:find(needle, pStart) + i, i2 = text:find(needle, pStart) if i == nil then local err = ('No match for "%s".'):format(needle) @@ -63,12 +63,12 @@ function TscFile:_stringReplace(text, needle, replacement, label, overrides) pStart = o+1 end - local len = needle:len() + local len = i2-i+1 local j = i + len - 1 assert((i % 1 == 0) and (i > 0) and (i <= j), tostring(i)) assert((j % 1 == 0), tostring(j)) local a = text:sub(1, i - 1) - local b = text:sub(j) + local b = text:sub(j + 1) return a .. replacement .. b, nil end