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)
|
||||
|
|
|
|||
1
spec/fixtures/impl/closer_output.go
vendored
1
spec/fixtures/impl/closer_output.go
vendored
|
|
@ -5,4 +5,3 @@ type CloserTest2 struct{}
|
|||
func (closertest *CloserTest2) Close() error {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
|
|
|
|||
1
spec/fixtures/impl/reader_output.go
vendored
1
spec/fixtures/impl/reader_output.go
vendored
|
|
@ -4,5 +4,4 @@ func (r Read2) Read(p []byte) (n int, err error) {
|
|||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
|
||||
type Read2 struct{}
|
||||
|
|
|
|||
1
spec/fixtures/impl/writer_output.go
vendored
1
spec/fixtures/impl/writer_output.go
vendored
|
|
@ -5,4 +5,3 @@ type WriterTest2 struct{}
|
|||
func (w *WriterTest2) Write(p []byte) (n int, err error) {
|
||||
panic("not implemented") // TODO: Implement
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue