1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-15 19:45:46 +08:00

refactor(format): refactor on_exit function

This commit is contained in:
Eric Wong 2024-04-16 14:35:15 +08:00
parent 17a380aed9
commit c9fd7f91c7

View File

@ -31,15 +31,12 @@ local function on_exit(id, code, single)
.. single .. single
) )
if code == 0 and single == 0 then if code == 0 and single == 0 then
local formatted_context
if current_task.formatter.use_stderr then if current_task.formatter.use_stderr then
vim.api.nvim_buf_set_lines( formatted_context = stderr
current_task.bufnr,
current_task.start_line,
current_task.end_line,
false,
stderr
)
else else
formatted_context = stdout
end
if table.concat(stdout, '\n') == table.concat(current_task.stdin, '\n') then if table.concat(stdout, '\n') == table.concat(current_task.stdin, '\n') then
util.msg('no necessary changes') util.msg('no necessary changes')
else else
@ -49,10 +46,9 @@ local function on_exit(id, code, single)
current_task.start_line, current_task.start_line,
current_task.end_line, current_task.end_line,
false, false,
stdout formatted_context
) )
end end
end
else else
util.msg('formatter ' .. current_task.formatter.exe .. ' failed to run') util.msg('formatter ' .. current_task.formatter.exe .. ' failed to run')
end end