Skip to content

Commit

Permalink
fix(windows): uv.process_kill(job) don't kill jobs correctly on win…
Browse files Browse the repository at this point in the history
…dows when you specify the priority → Neovim bug?
  • Loading branch information
Zeioth committed Feb 15, 2024
1 parent d7516ae commit 235f113
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lua/markmap/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,30 @@ M.setup = function(ctx)
cmd("MarkmapOpen", function()
reset_arguments()
table.insert(arguments, vim.fn.expand "%:p") -- current buffer path
if job ~= nil then uv.process_kill(job, 9) end
if job ~= nil then uv.process_kill(job) end
job = uv.spawn(run_markmap, { args = arguments }, nil)
end, { desc = "Show a mental map of the current file" })

cmd("MarkmapSave", function()
reset_arguments()
table.insert(arguments, "--no-open") -- specific to this command
table.insert(arguments, vim.fn.expand "%:p") -- current buffer path
if job ~= nil then uv.process_kill(job, 9) end -- kill -9 jobs
if job ~= nil then uv.process_kill(job) end -- kill jobs
job = uv.spawn(run_markmap, { args = arguments }, nil)
end, { desc = "Save the HTML file without opening the mindmap" })

cmd("MarkmapWatch", function()
reset_arguments()
table.insert(arguments, "--watch") -- spetific to this command
table.insert(arguments, vim.fn.expand "%:p") -- current buffer path
if job ~= nil then uv.process_kill(job, 9) end
if job ~= nil then uv.process_kill(job) end
job = uv.spawn(run_markmap, { args = arguments }, nil)
end,
{ desc = "Show a mental map of the current file and watch for changes" }
)

cmd("MarkmapWatchStop", function()
if job ~= nil then uv.process_kill(job, 9) end -- kill -9 jobs
if job ~= nil then uv.process_kill(job) end -- kill jobs
end, { desc = "Manually stops markmap watch" })

-- Autocmds --------------------------------------------------------------
Expand All @@ -105,7 +105,7 @@ M.setup = function(ctx)
-- Otherwise, use grace_period
local current_time = uv.now()
if current_time - last_execution >= grace_period then -- if grace period exceeded
if job ~= nil then uv.process_kill(job, 9) end -- pkill -9 jobs
if job ~= nil then uv.process_kill(job) end -- pkill jobs
last_execution = current_time -- update time
end
end,
Expand All @@ -116,7 +116,7 @@ M.setup = function(ctx)
desc = "Kill all markmap jobs before closing nvim",
group = augroup("markmap_kill_pre_exit_nvim", { clear = true }),
callback = function()
if job ~= nil then uv.process_kill(job, 9) end -- kill -9 jobs
if job ~= nil then uv.process_kill(job) end -- kill jobs
end,
})
end
Expand Down

0 comments on commit 235f113

Please sign in to comment.