Based on the error string.gsub takes string values as parameters and are at some cases being given nil values instead, so i wrote a simple check to always make sure line and space_text are string values
M.replace_line_content = function(line, space_text)
-- avoid nil values coming from line or space_text
-- string.gsub takes only string values and will throw annoying errors if it gets nil
if not line or line == '' then
return line
end
space_text= space_text or ''
line = string.gsub(line, '\v^(\\s*).*', '\\1')
line = string.gsub(line, '\t', space_text)
return line
end
Based on the error string.gsub takes string values as parameters and are at some cases being given nil values instead, so i wrote a simple check to always make sure line and space_text are string values