@@ -4,10 +4,6 @@ local child = helpers.new_child_neovim()
44local expect , eq = helpers .expect , helpers .expect .equality
55local new_set = MiniTest .new_set
66
7- local skip_if_no_010 = function ()
8- if child .fn .has (' nvim-0.10' ) == 0 then MiniTest .skip (' `setup_termbg_sync()` works only on Neovim>=0.10' ) end
9- end
10-
117local project_root = vim .fs .normalize (vim .fn .fnamemodify (vim .fn .getcwd (), ' :p' ))
128local dir_misc_path = project_root .. ' /tests/dir-misc'
139
662658T [' setup_termbg_sync()' ] = new_set ({
663659 hooks = {
664660 pre_case = function ()
661+ if child .fn .has (' nvim-0.10' ) == 0 then MiniTest .skip (' `setup_termbg_sync()` works only on Neovim>=0.10' ) end
662+
665663 child .lua ([[
666664 -- Mock `io.stdout:write` used to send control sequences to terminal emulator
667665 _G.log = {}
682680T [' setup_termbg_sync()' ][' works' ] = new_set (
683681 -- Neovim=0.10 uses string sequence as response, while Neovim>=0.11 sets it
684682 -- in `sequence` table field
685- { parametrize = { { ' \27 ]11;rgb:1111/2626/2d2d' }, { { sequence = ' \27 ]11;rgb:1111/2626/2d2d' } } } },
683+ { parametrize = { { ' \027 ]11;rgb:1111/2626/2d2d' }, { { sequence = ' \027 ]11;rgb:1111/2626/2d2d' } } } },
686684 {
687685 test = function (response_data )
688- skip_if_no_010 ()
689-
690686 local eq_log = function (ref_log )
691687 eq (child .lua_get (' _G.log' ), ref_log )
692688 child .lua (' _G.log = {}' )
@@ -718,18 +714,16 @@ T['setup_termbg_sync()']['works'] = new_set(
718714)
719715
720716T [' setup_termbg_sync()' ][' can be called multiple times' ] = function ()
721- skip_if_no_010 ()
722-
723717 child .cmd (' hi Normal guifg=#222222 guibg=#dddddd' )
724718 child .lua (' MiniMisc.setup_termbg_sync()' )
725- child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \27 ]11;rgb:1111/2626/2d2d' })
726- eq (child .lua_get (' _G.log' ), { { ' \27 ]11;?\a ' }, { ' \27 ]11;#dddddd\a ' } })
719+ child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \027 ]11;rgb:1111/2626/2d2d' })
720+ eq (child .lua_get (' _G.log' ), { { ' \027 ]11;?\a ' }, { ' \027 ]11;#dddddd\a ' } })
727721 child .lua (' _G.log = {}' )
728722
729723 -- If called second time, the terminal background color is already synced
730724 child .lua (' MiniMisc.setup_termbg_sync()' )
731- child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \27 ]11;rgb:dddd/dddd/dddd' })
732- eq (child .lua_get (' _G.log' ), { { ' \27 ]11;?\a ' }, { ' \27 ]11;#dddddd\a ' } })
725+ child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \027 ]11;rgb:dddd/dddd/dddd' })
726+ eq (child .lua_get (' _G.log' ), { { ' \027 ]11;?\a ' }, { ' \027 ]11;#dddddd\a ' } })
733727 child .lua (' _G.log = {}' )
734728
735729 -- Should reset to the color from the very first call
@@ -738,8 +732,6 @@ T['setup_termbg_sync()']['can be called multiple times'] = function()
738732end
739733
740734T [' setup_termbg_sync()' ][' does nothing if there is no proper stdout' ] = function ()
741- skip_if_no_010 ()
742-
743735 local validate = function ()
744736 child .lua (' MiniMisc.setup_termbg_sync()' )
745737 child .api .nvim_create_augroup (' MiniMiscTermbgSync' , { clear = false })
@@ -756,8 +748,6 @@ T['setup_termbg_sync()']['does nothing if there is no proper stdout'] = function
756748end
757749
758750T [' setup_termbg_sync()' ][' handles no response from terminal emulator' ] = function ()
759- skip_if_no_010 ()
760-
761751 child .lua (' _G.notify_log = {}; vim.notify = function(...) table.insert(_G.notify_log, { ... }) end' )
762752 child .lua (' MiniMisc.setup_termbg_sync()' )
763753 validate_termbg_augroup (true )
@@ -775,8 +765,6 @@ T['setup_termbg_sync()']['handles no response from terminal emulator'] = functio
775765end
776766
777767T [' setup_termbg_sync()' ][' handles bad response from terminal emulator' ] = function ()
778- skip_if_no_010 ()
779-
780768 child .lua (' _G.notify_log = {}; vim.notify = function(...) table.insert(_G.notify_log, { ... }) end' )
781769 child .lua (' MiniMisc.setup_termbg_sync()' )
782770
@@ -802,8 +790,6 @@ T['setup_termbg_sync()']['handles bad response from terminal emulator'] = functi
802790end
803791
804792T [' setup_termbg_sync()' ][' handles parallel unrelated `TermResponse` events' ] = function ()
805- skip_if_no_010 ()
806-
807793 child .lua (' _G.notify_log = {}; vim.notify = function(...) table.insert(_G.notify_log, { ... }) end' )
808794 child .lua (' MiniMisc.setup_termbg_sync()' )
809795
@@ -819,7 +805,7 @@ T['setup_termbg_sync()']['handles parallel unrelated `TermResponse` events'] = f
819805
820806 -- After receiving proper response should immediately stop waiting for it and
821807 -- set up proper `termbg` autocommands
822- local seq = ' \27 ]11;rgb:1111/2626/2d2d'
808+ local seq = ' \027 ]11;rgb:1111/2626/2d2d'
823809 local data = child .fn .has (' nvim-0.11' ) == 1 and { sequence = seq } or seq
824810 child .api .nvim_exec_autocmds (' TermResponse' , { data = data })
825811 validate_termbg_augroup (true )
@@ -829,13 +815,11 @@ T['setup_termbg_sync()']['handles parallel unrelated `TermResponse` events'] = f
829815end
830816
831817T [' setup_termbg_sync()' ][' handles different color formats' ] = function ()
832- skip_if_no_010 ()
833-
834818 local validate = function (term_response_color )
835819 -- Mock clean start to overcome that color is parsed only once per session
836820 child .lua (' package.loaded["mini.misc"] = nil' )
837821 child .lua (' require("mini.misc").setup_termbg_sync()' )
838- child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \27 ]11;' .. term_response_color })
822+ child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \027 ]11;' .. term_response_color })
839823
840824 -- Should properly parse initial background and use it to reset on exit
841825 child .lua (' _G.log = {}' )
@@ -861,11 +845,9 @@ T['setup_termbg_sync()']['handles different color formats'] = function()
861845end
862846
863847T [' setup_termbg_sync()' ][' handles transparent `Normal` background' ] = function ()
864- skip_if_no_010 ()
865-
866848 child .cmd (' hi Normal guifg=#222222 guibg=#dddddd' )
867849 child .lua (' MiniMisc.setup_termbg_sync()' )
868- child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \27 ]11;rgb:1111/2626/2d2d' })
850+ child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \027 ]11;rgb:1111/2626/2d2d' })
869851 child .lua (' _G.log = {}' )
870852
871853 -- When syncing with "transparent" `Normal`, should restore the original
@@ -876,8 +858,6 @@ T['setup_termbg_sync()']['handles transparent `Normal` background'] = function()
876858end
877859
878860T [' setup_termbg_sync()' ][' respects `opts.explicit_reset`' ] = function ()
879- skip_if_no_010 ()
880-
881861 child .cmd (' hi Normal guifg=#222222 guibg=#dddddd' )
882862 child .lua (' MiniMisc.setup_termbg_sync({ explicit_reset = true })' )
883863 child .api .nvim_exec_autocmds (' TermResponse' , { data = ' \027 ]11;rgb:1111/2626/2d2d' })
0 commit comments