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
+8 -11
View File
@@ -1,5 +1,6 @@
local log = require("log")
local repo = require("git.repo")
local util = require("util")
local M = {}
@@ -58,16 +59,6 @@ local function git_cmds()
return cached_cmds or {}
end
---@param content string
---@return string[]
local function 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
---@param args string[]
---@param start integer
---@return string?
@@ -116,7 +107,13 @@ local function run_in_split(worktree, args, conf)
end
local content = (obj.stdout or "") .. (obj.stderr or "")
vim.bo[buf].modifiable = true
vim.api.nvim_buf_set_lines(buf, 0, -1, false, split_lines(content))
vim.api.nvim_buf_set_lines(
buf,
0,
-1,
false,
util.split_lines(content)
)
vim.bo[buf].modifiable = false
vim.bo[buf].modified = false
if obj.code ~= 0 then