aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-11-28 16:34:18 -0600
committerGitHub <noreply@github.com>2023-11-28 16:34:18 -0600
commitb7831c7f996b769544d2bdc536ef601eb46b4918 (patch)
tree5f6e0562daf552177427b2b837de58375c0bfd53
parent79b6ff28ad1204fbb4199b9092f5c578d88cb28e (diff)
downloadrneovim-b7831c7f996b769544d2bdc536ef601eb46b4918.tar.gz
rneovim-b7831c7f996b769544d2bdc536ef601eb46b4918.tar.bz2
rneovim-b7831c7f996b769544d2bdc536ef601eb46b4918.zip
fix(termcap): use tmux passthrough sequence when running in tmux (#26281)
tmux intercepts and ignores XTGETTCAP so wrap the query in the tmux passthrough sequence to make sure the query arrives at the "host" terminal. Users must still set the 'allow-passthrough' option in their tmux.conf.
-rw-r--r--runtime/lua/vim/termcap.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/lua/vim/termcap.lua b/runtime/lua/vim/termcap.lua
index 0eefc5eee4..2117f287cb 100644
--- a/runtime/lua/vim/termcap.lua
+++ b/runtime/lua/vim/termcap.lua
@@ -34,10 +34,6 @@ function M.query(caps, cb)
local seq =
vim.text.hexdecode(v):gsub('\\E', '\027'):gsub('%%p%d', ''):gsub('\\(%d+)', string.char)
- -- TODO: When libtermkey is patched to accept BEL as an OSC terminator, this workaround can
- -- be removed
- seq = seq:gsub('\007$', '\027\\')
-
cb(cap, seq)
count = count - 1
@@ -54,6 +50,12 @@ function M.query(caps, cb)
end
local query = string.format('\027P+q%s\027\\', table.concat(encoded, ';'))
+
+ -- If running in tmux, wrap with the passthrough sequence
+ if os.getenv('TMUX') then
+ query = string.format('\027Ptmux;\027%s\027\\', query)
+ end
+
io.stdout:write(query)
end