]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.1161: unreachable code v8.1.1161
authorBram Moolenaar <Bram@vim.org>
Fri, 12 Apr 2019 20:27:39 +0000 (22:27 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 12 Apr 2019 20:27:39 +0000 (22:27 +0200)
Problem:    Unreachable code.
Solution:   Remove condition that will never be true.  Add tests for all ANSI
            colors.

src/terminal.c
src/testdir/dumps/Test_terminal_all_ansi_colors.dump [new file with mode: 0644]
src/testdir/test_terminal.vim
src/version.c

index c7dc23f904b75ae4ad2f641442279c0db054aeca..c0777b2ed6c08cc0e42fc271605db587d8e93b30 100644 (file)
@@ -2432,10 +2432,7 @@ color2index(VTermColor *color, int fg, int *boldp)
 
     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;
diff --git a/src/testdir/dumps/Test_terminal_all_ansi_colors.dump b/src/testdir/dumps/Test_terminal_all_ansi_colors.dump
new file mode 100644 (file)
index 0000000..2799396
--- /dev/null
@@ -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| 
index e337c477561961e5c76d7c31b762debbe822f618..7268480b078717daf5a193b184561adda9e328c4 100644 (file)
@@ -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
index 81f0420b931905d55d0f03830d4b74023715b1d4..7d6e4495e5627038484dd87d5b30cf138c451768 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1161,
 /**/
     1160,
 /**/