patch 8.2.0455: cannot set the highlight group for a specific terminal
Problem: Cannot set the highlight group for a specific terminal.
Solution: Add the "highlight" option to term_start(). (closes #5818)
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index f3571d4..c48ff4e 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -2434,7 +2434,6 @@
let lines = [
\ 'set t_u7=',
\ 'call setline(1, range(20))',
- \ 'hi PopTerm ctermbg=grey',
\ 'func OpenTerm()',
\ " let s:buf = term_start('cat Xtext', #{hidden: 1})",
\ ' let g:winid = popup_create(s:buf, #{ border: []})',
@@ -2457,6 +2456,46 @@
call delete('XtermPopup')
endfunc
+" Check a terminal in popup window with different colors
+func Terminal_in_popup_colored(group_name, highlight_cmd, highlight_opt)
+ CheckRunVimInTerminal
+ CheckUnix
+
+ let lines = [
+ \ 'set t_u7=',
+ \ 'call setline(1, range(20))',
+ \ 'func OpenTerm()',
+ \ " let s:buf = term_start('cat', #{hidden: 1, "
+ \ .. a:highlight_opt .. "})",
+ \ ' let g:winid = popup_create(s:buf, #{ border: []})',
+ \ 'endfunc',
+ \ a:highlight_cmd,
+ \ ]
+ call writefile(lines, 'XtermPopup')
+ let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
+ call term_wait(buf, 200)
+ call term_sendkeys(buf, ":set noruler\<CR>")
+ call term_sendkeys(buf, ":call OpenTerm()\<CR>")
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, "hello\<CR>")
+ call VerifyScreenDump(buf, 'Test_terminal_popup_' .. a:group_name, {})
+
+ call term_sendkeys(buf, "\<C-D>")
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, ":q\<CR>")
+ call term_wait(buf, 100) " wait for terminal to vanish
+ call StopVimInTerminal(buf)
+ call delete('XtermPopup')
+endfunc
+
+func Test_terminal_in_popup_colored_Terminal()
+ call Terminal_in_popup_colored("Terminal", "highlight Terminal ctermfg=blue ctermbg=yellow", "")
+endfunc
+
+func Test_terminal_in_popup_colored_group()
+ call Terminal_in_popup_colored("MyTermCol", "highlight MyTermCol ctermfg=darkgreen ctermbg=lightblue", "term_highlight: 'MyTermCol',")
+endfunc
+
func Test_double_popup_terminal()
let buf1 = term_start(&shell, #{hidden: 1})
let win1 = popup_create(buf1, {})