aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/termcap.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-12-13 08:14:30 -0600
committerGitHub <noreply@github.com>2023-12-13 08:14:30 -0600
commite527842211188a5c069ef4f4759aa291353b707f (patch)
tree7ac61e6c0caf48b26356e3f89a668479a2ef2ae4 /runtime/lua/vim/termcap.lua
parentd65c6a0bafada059e87a11a4bcd129afc16d2e5d (diff)
downloadrneovim-e527842211188a5c069ef4f4759aa291353b707f.tar.gz
rneovim-e527842211188a5c069ef4f4759aa291353b707f.tar.bz2
rneovim-e527842211188a5c069ef4f4759aa291353b707f.zip
fix(termcap): only call callback for requested capabilities (#26546)
If multiple XTGETTCAP requests are active at once (for example, for requesting the Ms capability and truecolor capabilities), then the TermResponse autocommand may fire for capabilities that were not requested. Instead, make sure that the provided callback is only called for capabilities that were actually requested.
Diffstat (limited to 'runtime/lua/vim/termcap.lua')
-rw-r--r--runtime/lua/vim/termcap.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/lua/vim/termcap.lua b/runtime/lua/vim/termcap.lua
index b88d9ac9ba..e48657b3c2 100644
--- a/runtime/lua/vim/termcap.lua
+++ b/runtime/lua/vim/termcap.lua
@@ -39,6 +39,12 @@ function M.query(caps, cb)
local k, rest = resp:match('^\027P1%+r(%x+)(.*)$')
if k and rest then
local cap = vim.text.hexdecode(k)
+ if not pending[cap] then
+ -- Received a response for a capability we didn't request. This can happen if there are
+ -- multiple concurrent XTGETTCAP requests
+ return
+ end
+
local seq ---@type string?
if rest:match('^=%x+$') then
seq = vim.text