mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(defaults): validate 'channel' before responding to OSC request (#27594)
Validate the channel number before responding to an OSC 10/11 request. When used with nvim_open_term, the channel number is unset (since there is no process on the other side of the PTY).
This commit is contained in:
@ -143,6 +143,10 @@ do
|
|||||||
group = nvim_terminal_augroup,
|
group = nvim_terminal_augroup,
|
||||||
desc = 'Respond to OSC foreground/background color requests',
|
desc = 'Respond to OSC foreground/background color requests',
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
|
local channel = vim.bo[args.buf].channel
|
||||||
|
if channel == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
local fg_request = args.data == '\027]10;?'
|
local fg_request = args.data == '\027]10;?'
|
||||||
local bg_request = args.data == '\027]11;?'
|
local bg_request = args.data == '\027]11;?'
|
||||||
if fg_request or bg_request then
|
if fg_request or bg_request then
|
||||||
@ -157,7 +161,6 @@ do
|
|||||||
end
|
end
|
||||||
local command = fg_request and 10 or 11
|
local command = fg_request and 10 or 11
|
||||||
local data = string.format('\027]%d;rgb:%04x/%04x/%04x\007', command, red, green, blue)
|
local data = string.format('\027]%d;rgb:%04x/%04x/%04x\007', command, red, green, blue)
|
||||||
local channel = vim.bo[args.buf].channel
|
|
||||||
vim.api.nvim_chan_send(channel, data)
|
vim.api.nvim_chan_send(channel, data)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Reference in New Issue
Block a user