fedepujol / bracketpair.nvim

Colorized bracket scope in lua!
7 stars 2 forks source link

M.replace_line_content fix #6

Closed mAmineChniti closed 7 months ago

mAmineChniti commented 7 months ago

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