Skip to content

Commit

Permalink
fix: kill rojo sourcemap process on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
lopi-py committed Aug 30, 2024
1 parent be18460 commit b9ea154
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Support for Neovim 0.9

### Fixed

- Kill rojo sourcemap process on exit

## [1.6.0] - 2024-08-29

### Added
Expand Down
17 changes: 11 additions & 6 deletions lua/luau-lsp/roblox/sourcemap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ local function get_rojo_project_file(callback)
end
end

local function stop_sourcemap_generation()
if pid then
vim.uv.kill(pid)
end
end

---@param project_file? string
local function start_sourcemap_generation(project_file)
if not project_file then
Expand All @@ -56,13 +62,13 @@ local function start_sourcemap_generation(project_file)
table.insert(cmd, "--include-non-scripts")
end

local augroup = vim.api.nvim_create_augroup("luau-lsp/sourcemap", {})
local ok, job = pcall(vim.system, cmd, {
text = true,
}, function(result)
if result.stderr and result.stderr ~= "" then
log.error("Failed to update sourcemap for '%s': %s", project_file, result.stderr)
end
pid = nil
end)

if not ok then
Expand All @@ -72,12 +78,11 @@ local function start_sourcemap_generation(project_file)

log.info("Starting sourcemap generation for '%s'", project_file)
pid = job.pid
end

local function stop_sourcemap_generation()
if pid then
vim.uv.kill(pid)
end
vim.api.nvim_create_autocmd("VimLeavePre", {
group = augroup,
callback = stop_sourcemap_generation,
})
end

---@param project_file? string
Expand Down

0 comments on commit b9ea154

Please sign in to comment.