summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-12 22:27:39 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-12 22:27:39 +0200
commit1d79ce81e7be20405f0fa9687b37c86a2215e326 (patch)
tree03040323f670dd4465a42f31f9230fcd76c3d52b
parentc8b3ddab51cd2901d5946949d02c96e1035b25c0 (diff)
downloadvim-git-1d79ce81e7be20405f0fa9687b37c86a2215e326.tar.gz
patch 8.1.1161: unreachable codev8.1.1161
Problem: Unreachable code. Solution: Remove condition that will never be true. Add tests for all ANSI colors.
-rw-r--r--src/terminal.c5
-rw-r--r--src/testdir/dumps/Test_terminal_all_ansi_colors.dump10
-rw-r--r--src/testdir/test_terminal.vim51
-rw-r--r--src/version.c2
4 files changed, 64 insertions, 4 deletions
diff --git a/src/terminal.c b/src/terminal.c
index c7dc23f90..c0777b2ed 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -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
index 000000000..279939619
--- /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|
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index e337c4775..7268480b0 100644
--- 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
diff --git a/src/version.c b/src/version.c
index 81f0420b9..7d6e4495e 100644
--- 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,