diff options
author | Gregory Anders <greg@gpanders.com> | 2025-03-12 08:11:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-12 08:11:19 -0500 |
commit | 04181070746a51d2f11ce5fc96d2696ea267ff70 (patch) | |
tree | e271d9a3868b445a5b147267937a7411b224daed /test/functional | |
parent | 69a19295f8fe90356011eff2b7fa67b0593fffcc (diff) | |
download | rneovim-04181070746a51d2f11ce5fc96d2696ea267ff70.tar.gz rneovim-04181070746a51d2f11ce5fc96d2696ea267ff70.tar.bz2 rneovim-04181070746a51d2f11ce5fc96d2696ea267ff70.zip |
fix: update osc52 termfeatures flag on UIEnter/UILeave (#32756)
Problem:
Nvim tries to use OSC 52 even when no TUIs are attached.
Solution:
On each UIEnter/UILeave event, check that there is a TUI client connected to Nvim's stdout.
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 5e452ce9c9..37085a4e43 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -3329,6 +3329,55 @@ describe('TUI', function() retry(nil, 1000, function() eq({ true, { osc52 = true } }, { child_session:request('nvim_eval', 'g:termfeatures') }) end) + + -- Attach another (non-TUI) UI to the child instance + local alt = Screen.new(nil, nil, nil, child_session) + + -- Detach the first (primary) client so only the second UI is attached + feed_data(':detach\n') + + alt:expect({ any = '%[No Name%]' }) + + -- osc52 should be cleared from termfeatures + eq({ true, {} }, { child_session:request('nvim_eval', 'g:termfeatures') }) + + alt:detach() + end) + + it('does not query the terminal for OSC 52 support when disabled', function() + clear() + exec_lua([[ + _G.query = false + vim.api.nvim_create_autocmd('TermRequest', { + callback = function(args) + local req = args.data.sequence + local sequence = req:match('^\027P%+q([%x;]+)$') + if sequence and vim.text.hexdecode(sequence) == 'Ms' then + _G.query = true + end + end, + }) + ]]) + + local child_server = new_pipename() + screen = tt.setup_child_nvim({ + '--listen', + child_server, + -- Use --clean instead of -u NONE to load the osc52 plugin + '--clean', + '--cmd', + 'let g:termfeatures = #{osc52: v:false}', + }, { + env = { + VIMRUNTIME = os.getenv('VIMRUNTIME'), + }, + }) + + screen:expect({ any = '%[No Name%]' }) + + local child_session = n.connect(child_server) + eq({ true, { osc52 = false } }, { child_session:request('nvim_eval', 'g:termfeatures') }) + eq(false, exec_lua([[return _G.query]])) end) end) |