refactor!: dont add unnecessary empty lines

This commit is contained in:
Oleksandr Smirnov 2025-02-26 20:26:33 +02:00
parent 02cc77e81c
commit 5b233d877c
No known key found for this signature in database
6 changed files with 14 additions and 5 deletions

View file

@ -30,4 +30,16 @@ function utils.readfile_joined(path)
return table.concat(vim.fn.readfile(path), "\n") return table.concat(vim.fn.readfile(path), "\n")
end 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 return utils

View file

@ -30,7 +30,7 @@ function iferr.iferr()
error("iferr failed: " .. rs.stderr) error("iferr failed: " .. rs.stderr)
end 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.cmd [[silent normal! j=2j]]
vim.fn.setpos(".", pos) vim.fn.setpos(".", pos)
end end

View file

@ -88,7 +88,7 @@ function impl.impl(...)
end end
local pos = vim.fn.getcurpos()[2] 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, "") table.insert(output, 1, "")
vim.fn.append(pos, output) vim.fn.append(pos, output)

View file

@ -5,4 +5,3 @@ type CloserTest2 struct{}
func (closertest *CloserTest2) Close() error { func (closertest *CloserTest2) Close() error {
panic("not implemented") // TODO: Implement panic("not implemented") // TODO: Implement
} }

View file

@ -4,5 +4,4 @@ func (r Read2) Read(p []byte) (n int, err error) {
panic("not implemented") // TODO: Implement panic("not implemented") // TODO: Implement
} }
type Read2 struct{} type Read2 struct{}

View file

@ -5,4 +5,3 @@ type WriterTest2 struct{}
func (w *WriterTest2) Write(p []byte) (n int, err error) { func (w *WriterTest2) Write(p []byte) (n int, err error) {
panic("not implemented") // TODO: Implement panic("not implemented") // TODO: Implement
} }