fix: keep correct indentation (#710)

This commit is contained in:
yetone
2024-10-11 21:07:55 +08:00
committed by GitHub
parent 134609a04c
commit faaa7f223b
3 changed files with 19 additions and 7 deletions

View File

@@ -446,10 +446,16 @@ end
---@param code string
---@return string
function M.get_indentation(code) return code:match("^%s*") or "" end
function M.get_indentation(code)
if not code then return "" end
return code:match("^%s*") or ""
end
--- remove indentation from code: spaces or tabs
function M.remove_indentation(code) return code:gsub("^%s*", "") end
function M.remove_indentation(code)
if not code then return code end
return code:gsub("^%s*", "")
end
function M.relative_path(absolute)
local relative = fn.fnamemodify(absolute, ":.")