diff options
| author | Barrett Ruth <62671086+barrettruth@users.noreply.github.com> | 2026-06-23 05:19:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-23 06:19:56 -0400 |
| commit | db30608058db402de37be7a1d33fa60b7fc7de83 (patch) | |
| tree | 20fdd838c3e8237215639b9b3d3bf99556d1a5cd /runtime/lua/vim/tty.lua | |
| parent | e4fbe162c193f926000bc83123e40caf8faccb14 (diff) | |
| download | rneovim-db30608058db402de37be7a1d33fa60b7fc7de83.tar.gz rneovim-db30608058db402de37be7a1d33fa60b7fc7de83.tar.bz2 rneovim-db30608058db402de37be7a1d33fa60b7fc7de83.zip | |
fix(tui): attribute `TermResponse` to source channel #40330
Problem: Attach-time terminal probes cannot distinguish responses from
different attached UIs.
Solution: Identify the UI by RPC channel id in `TermResponse` and make
`vim.tty.request()` filter responses by channel.
Diffstat (limited to 'runtime/lua/vim/tty.lua')
| -rw-r--r-- | runtime/lua/vim/tty.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/tty.lua b/runtime/lua/vim/tty.lua index 6771efe849..06b8eddcec 100644 --- a/runtime/lua/vim/tty.lua +++ b/runtime/lua/vim/tty.lua @@ -10,10 +10,11 @@ local M = {} --- ---@param payload string Sequence to send via nvim_ui_send(). Use empty string ('') to just register --- a listener (no sending). ----@param opts? { timeout?: integer, on_timeout?: fun(), group?: integer|string } +---@param opts? { timeout?: integer, on_timeout?: fun(), group?: integer|string, chan?: integer } --- - `timeout` (default: 1000) ms to wait before giving up, or 0 for never (caller must remove the autocmd). --- - `on_timeout` optional fn called when the timeout fires. --- - `group`: augroup for the TermResponse autocmd. +--- - `chan`: only handle responses from this channel. ---@param on_response fun(resp:string):boolean? Called for each TermResponse. Return `true` to stop listening. ---@return integer # autocmd id of the TermResponse handler. function M.request(payload, opts, on_response) @@ -32,7 +33,11 @@ function M.request(payload, opts, on_response) 'TermResponse', opts.group, { nested = true }, + ---@param ev {data: vim.event.termresponse.data} function(ev) + if opts.chan and ev.data.chan ~= opts.chan then + return + end local stop = on_response(ev.data.sequence) -- If on_response is done, cancel the timeout so on_timeout doesn't fire spuriously. if stop and timer and not timer:is_closing() then |