From ce597235a26839826de88ecd8b949ec54c310fbd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Feb 2023 16:31:05 +0100 Subject: feat(ui): restore has('gui_running') Problem: has('gui_running') is still common in the wild and our answer has changed over time, causing frustration. https://github.com/vimpostor/vim-tpipeline/commit/95a6ccbe9f33bc42dd4cee45731d8bc3fbcd92d1 Solution: Use stdin_tty/stdout_tty to decide if a UI is (not) a GUI. --- test/functional/vimscript/has_spec.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'test/functional/vimscript/has_spec.lua') diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua index 2e26d603b3..78a761d370 100644 --- a/test/functional/vimscript/has_spec.lua +++ b/test/functional/vimscript/has_spec.lua @@ -1,8 +1,11 @@ local helpers = require('test.functional.helpers')(after_each) -local eq = helpers.eq +local Screen = require('test.functional.ui.screen') local clear = helpers.clear +local connect = helpers.connect +local eq = helpers.eq local funcs = helpers.funcs local is_os = helpers.is_os +local nvim_prog = helpers.nvim_prog describe('has()', function() before_each(clear) @@ -69,8 +72,22 @@ describe('has()', function() end end) + it('"gui_running"', function() + eq(0, funcs.has('gui_running')) + local tui = Screen.new(50,15) + local gui_session = connect(funcs.serverstart()) + local gui = Screen.new(50,15) + eq(0, funcs.has('gui_running')) + tui:attach({ext_linegrid=true, rgb=true, stdin_tty=true, stdout_tty=true}) + gui:attach({ext_multigrid=true, rgb=true}, gui_session) + eq(1, funcs.has('gui_running')) + tui:detach() + eq(1, funcs.has('gui_running')) + gui:detach() + eq(0, funcs.has('gui_running')) + end) + it('does not change v:shell_error', function() - local nvim_prog = helpers.nvim_prog funcs.system({nvim_prog, '-es', '+73cquit'}) funcs.has('python3') -- use a call whose implementation shells out eq(73, funcs.eval('v:shell_error')) -- cgit