mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(image): work around tmux extended-keys breaking TermResponse. Closes #2332
When tmux has extended-keys enabled, Neovim's TermResponse autocmd doesn't fire,
causing terminal response sequences to leak as literal text into buffers.
Workaround: Detect this configuration and query tmux directly for the terminal
name using `tmux display-message -p "#{client_termname}"` instead of sending
escape sequences.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
277ba028b3
commit
e93dcfdf39
1 changed files with 12 additions and 0 deletions
|
|
@ -230,6 +230,18 @@ function M.detect(cb)
|
|||
M.transform = function(data)
|
||||
return ("\027Ptmux;" .. data:gsub("\027", "\027\027")) .. "\027\\"
|
||||
end
|
||||
-- NOTE: When tmux has extended-keys enabled, Neovim's TermResponse autocmd doesn't fire.
|
||||
-- Terminal response sequences leak as literal text instead of being captured.
|
||||
-- Workaround: Query tmux directly for the terminal name instead of sending escape sequences.
|
||||
-- See: https://github.com/folke/snacks.nvim/issues/2332
|
||||
local ok, out = pcall(vim.fn.system, { "tmux", "show", "-g", "extended-keys" })
|
||||
if ok and vim.trim(out):find(" on$") then
|
||||
ok, out = pcall(vim.fn.system, { "tmux", "display-message", "-p", "#{client_termname}" })
|
||||
if ok then
|
||||
ret.terminal = vim.trim(out):gsub("^xterm%-", "")
|
||||
return vim.schedule(on_done)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local id = vim.api.nvim_create_autocmd("TermResponse", {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue