refactor!: dont add unnecessary empty lines
This commit is contained in:
parent
02cc77e81c
commit
5b233d877c
6 changed files with 14 additions and 5 deletions
|
|
@ -30,4 +30,16 @@ function utils.readfile_joined(path)
|
|||
return table.concat(vim.fn.readfile(path), "\n")
|
||||
end
|
||||
|
||||
---@param t string[]
|
||||
---@return string[]
|
||||
function utils.remove_empty_lines(t)
|
||||
local res = {}
|
||||
for _, line in ipairs(t) do
|
||||
if line ~= "" then
|
||||
table.insert(res, line)
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
return utils
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function iferr.iferr()
|
|||
error("iferr failed: " .. rs.stderr)
|
||||
end
|
||||
|
||||
vim.fn.append(pos, vim.split(rs.stdout, "\n"))
|
||||
vim.fn.append(pos, u.remove_empty_lines(vim.split(rs.stdout, "\n")))
|
||||
vim.cmd [[silent normal! j=2j]]
|
||||
vim.fn.setpos(".", pos)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ function impl.impl(...)
|
|||
end
|
||||
|
||||
local pos = vim.fn.getcurpos()[2]
|
||||
local output = vim.split(rs.stdout, "\n")
|
||||
local output = u.remove_empty_lines(vim.split(rs.stdout, "\n"))
|
||||
|
||||
table.insert(output, 1, "")
|
||||
vim.fn.append(pos, output)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue