Skip to content

Commit

Permalink
fix: raise error if channel_id not found
Browse files Browse the repository at this point in the history
if channel_id is not found, something went wrong. neovim can't use broadcast channel_id 0 to make an
rpc request.
  • Loading branch information
wallpants committed Oct 15, 2023
1 parent 91a3e1f commit 94c64ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/github-preview/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ local function client_channel(client_name)
return chan.id
end
end
-- return broadcast channel if client not found
return 0

vim.notify("github-preview: channel_id not found", vim.log.levels.ERROR)
return nil
end

---@param opts nvim_plugin_opts
Expand Down Expand Up @@ -77,6 +78,9 @@ M.setup = function(opts)
local function stop_service()
if job_id ~= nil then
local channel_id = client_channel("github-preview")
if channel_id == nil then
return
end
-- VimLeavePre request closes browser
vim.rpcrequest(channel_id, "VimLeavePre")
local stopSuccess = vim.fn.jobstop(job_id)
Expand Down

0 comments on commit 94c64ad

Please sign in to comment.