changeset 16312:46e8430738fa v8.1.1161

patch 8.1.1161: unreachable code commit https://github.com/vim/vim/commit/1d79ce81e7be20405f0fa9687b37c86a2215e326 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 12 22:27:39 2019 +0200 patch 8.1.1161: unreachable code Problem: Unreachable code. Solution: Remove condition that will never be true. Add tests for all ANSI colors.
author Bram Moolenaar <Bram@vim.org>
date Fri, 12 Apr 2019 22:30:08 +0200
parents 94ca56fd6b64
children 805637c2c0fd
files src/terminal.c src/testdir/dumps/Test_terminal_all_ansi_colors.dump src/testdir/test_terminal.vim src/version.c
diffstat 4 files changed, 64 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -2432,10 +2432,7 @@ color2index(VTermColor *color, int fg, i
 
     if (color->ansi_index != VTERM_ANSI_INDEX_NONE)
     {
-	/* First 16 colors and default: use the ANSI index, because these
-	 * colors can be redefined, we use the RGB values. */
-	if (t_colors > 256)
-	    return color->ansi_index;
+	// The first 16 colors and default: use the ANSI index.
 	switch (color->ansi_index)
 	{
 	    case  0: return 0;
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_terminal_all_ansi_colors.dump
@@ -0,0 +1,10 @@
+>A+0#0000001#e0e0e08@1|B+0#e000002#ff404010@1|C+0#00e0003#40ff4011@1|D+0#af5f00255#ffffff0@1|E+0#0000e05#4040ff13@1|F+0#e000e06#ff40ff14@1|G+0#00e0e07#40ffff15@1|H+0#e0e0e08#0000001@1|I+0#6c6c6c255#ffffff16@1|J+0#ff404010#e000002@1|K+0#40ff4011#00e0003@1|L+0#ffff4012#af5f00255@1|M+0#4040ff13#0000e05@1|N+0#ff40ff14#e000e06@1|O+0#40ffff15#00e0e07@1|P+0#ffffff16#6c6c6c255@1| +0#0000000#ffffff0@42
+@2| +0#4040ff13&@72
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1484,6 +1484,57 @@ func Test_terminal_ansicolors_func()
   exe buf . 'bwipe'
 endfunc
 
+func Test_terminal_all_ansi_colors()
+  if !CanRunVimInTerminal()
+    return
+  endif
+
+  " Use all the ANSI colors.
+  call writefile([
+	\ 'call setline(1, "AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPP")',
+	\ 'hi Tblack ctermfg=Black ctermbg=Lightgrey',
+	\ 'hi Tdarkred ctermfg=Darkred ctermbg=Red',
+	\ 'hi Tdarkgreen ctermfg=Darkgreen ctermbg=Green',
+	\ 'hi Tbrown ctermfg=Brown ctermbg=Yello',
+	\ 'hi Tdarkblue ctermfg=Darkblue ctermbg=Blue',
+	\ 'hi Tdarkmagenta ctermfg=Darkmagenta ctermbg=Magenta',
+	\ 'hi Tdarkcyan ctermfg=Darkcyan ctermbg=Cyan',
+	\ 'hi Tlightgrey ctermfg=Lightgrey ctermbg=Black',
+	\ 'hi Tdarkgrey ctermfg=Darkgrey ctermbg=White',
+	\ 'hi Tred ctermfg=Red ctermbg=Darkred',
+	\ 'hi Tgreen ctermfg=Green ctermbg=Darkgreen',
+	\ 'hi Tyellow ctermfg=Yellow ctermbg=Brown',
+	\ 'hi Tblue ctermfg=Blue ctermbg=Darkblue',
+	\ 'hi Tmagenta ctermfg=Magenta ctermbg=Darkmagenta',
+	\ 'hi Tcyan ctermfg=Cyan ctermbg=Darkcyan',
+	\ 'hi Twhite ctermfg=White ctermbg=Darkgrey',
+	\ '',
+	\ 'call  matchadd("Tblack", "A")',
+	\ 'call  matchadd("Tdarkred", "B")',
+	\ 'call  matchadd("Tdarkgreen", "C")',
+	\ 'call  matchadd("Tbrown", "D")',
+	\ 'call  matchadd("Tdarkblue", "E")',
+	\ 'call  matchadd("Tdarkmagenta", "F")',
+	\ 'call  matchadd("Tdarkcyan", "G")',
+	\ 'call  matchadd("Tlightgrey", "H")',
+	\ 'call  matchadd("Tdarkgrey", "I")',
+	\ 'call  matchadd("Tred", "J")',
+	\ 'call  matchadd("Tgreen", "K")',
+	\ 'call  matchadd("Tyellow", "L")',
+	\ 'call  matchadd("Tblue", "M")',
+	\ 'call  matchadd("Tmagenta", "N")',
+	\ 'call  matchadd("Tcyan", "O")',
+	\ 'call  matchadd("Twhite", "P")',
+	\ 'redraw',
+	\ ], 'Xcolorscript')
+  let buf = RunVimInTerminal('-S Xcolorscript', {'rows': 10})
+  call VerifyScreenDump(buf, 'Test_terminal_all_ansi_colors', {})
+
+  call term_sendkeys(buf, ":q\<CR>")
+  call StopVimInTerminal(buf)
+  call delete('Xcolorscript')
+endfunc
+
 func Test_terminal_termwinsize_option_fixed()
   if !CanRunVimInTerminal()
     return
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1161,
+/**/
     1160,
 /**/
     1159,