refactor(git): extract util.split_lines helper

This commit is contained in:
2026-04-27 13:39:23 +02:00
parent 50697cfe98
commit 4b8d551b0d
5 changed files with 27 additions and 33 deletions
+13
View File
@@ -428,4 +428,17 @@ function M.get_hl_source(name)
return hl
end
---Split a string on newlines, dropping the trailing empty element that an
---input ending in `\n` produces. Convenient for slicing subprocess stdout
---into a list of lines without a phantom blank at the end.
---@param content string
---@return string[]
function M.split_lines(content)
local lines = vim.split(content, "\n", { plain = true, trimempty = false })
if #lines > 0 and lines[#lines] == "" then
table.remove(lines)
end
return lines
end
return M