From fa17a5ab49dff5a2e4de7bd2faee31f5458993aa Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:31:37 -0600 Subject: fix(terminal): use terminal buffer for TermRequest autocommand (#26974) --- test/functional/terminal/buffer_spec.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test/functional') diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index d0462b5619..497d7668e8 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -318,16 +318,23 @@ describe(':terminal buffer', function() ) end) - it('emits TermRequest events', function() + it('emits TermRequest events #26972', function() command('split') command('enew') local term = meths.open_term(0, {}) + local termbuf = meths.get_current_buf().id + + -- Test that autocommand buffer is associated with the terminal buffer, not the current buffer + command('au TermRequest * let g:termbuf = +expand("")') + command('wincmd p') + -- cwd will be inserted in a file URI, which cannot contain backs local cwd = funcs.getcwd():gsub('\\', '/') local parent = cwd:match('^(.+/)') local expected = '\027]7;file://host' .. parent meths.chan_send(term, string.format('%s\027\\', expected)) eq(expected, eval('v:termrequest')) + eq(termbuf, eval('g:termbuf')) end) end) -- cgit