summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-24 17:23:45 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-24 17:23:45 +0200
commit87202264f8e27f084c0e58f98aeb27fa5c6d5251 (patch)
tree759227c129d05bbc533dc54554258a9f303ada5f
parent9c65253fe702ea010afec11aa971acd542c35de2 (diff)
downloadvim-git-87202264f8e27f084c0e58f98aeb27fa5c6d5251.tar.gz
patch 8.2.0816: terminal test fails when compiled with Athenav8.2.0816
Problem: Terminal test fails when compiled with Athena. Solution: Do give an error when the GUI is not running. (hint by Dominique Pelle, closes #5928, closes #6132)
-rw-r--r--src/channel.c6
-rw-r--r--src/globals.h3
-rw-r--r--src/gui.c2
-rw-r--r--src/term.c10
-rw-r--r--src/testdir/test_terminal.vim14
-rw-r--r--src/version.c2
6 files changed, 27 insertions, 10 deletions
diff --git a/src/channel.c b/src/channel.c
index 68adbc378..2b85ec91d 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -5308,6 +5308,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
{
char_u *color_name;
guicolor_T guicolor;
+ int called_emsg_before = called_emsg;
color_name = tv_get_string_chk(&li->li_tv);
if (color_name == NULL)
@@ -5315,7 +5316,12 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
guicolor = GUI_GET_COLOR(color_name);
if (guicolor == INVALCOLOR)
+ {
+ if (called_emsg_before == called_emsg)
+ // may not get the error if the GUI didn't start
+ semsg(_(e_alloc_color), color_name);
return FAIL;
+ }
rgb[n] = GUI_MCH_GET_RGB(guicolor);
}
diff --git a/src/globals.h b/src/globals.h
index 60c3c668b..648da7dce 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1767,6 +1767,9 @@ EXTERN char e_no_white_before[] INIT(= N_("E1068: No white space allowed before
EXTERN char e_lock_unlock[] INIT(= N_("E940: Cannot lock or unlock variable %s"));
#endif
+#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+EXTERN char e_alloc_color[] INIT(= N_("E254: Cannot allocate color %s"));
+#endif
#ifdef FEAT_GUI_MAC
EXTERN short disallow_gui INIT(= FALSE);
diff --git a/src/gui.c b/src/gui.c
index 13b65cb03..93b8bb63f 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4741,7 +4741,7 @@ gui_get_color(char_u *name)
&& gui.in_use
#endif
)
- semsg(_("E254: Cannot allocate color %s"), name);
+ semsg(_(e_alloc_color), name);
return t;
}
diff --git a/src/term.c b/src/term.c
index e79fa5eb2..588058941 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1381,7 +1381,7 @@ termgui_get_color(char_u *name)
t = termgui_mch_get_color(name);
if (t == INVALCOLOR)
- semsg(_("E254: Cannot allocate color %s"), name);
+ semsg(_(e_alloc_color), name);
return t;
}
@@ -1587,9 +1587,9 @@ may_adjust_color_count(int val)
log_tr("Received t_Co, redraw_asap(): %d", r);
}
-#else
+# else
redraw_asap(CLEAR);
-#endif
+# endif
}
}
#endif
@@ -1597,10 +1597,10 @@ may_adjust_color_count(int val)
#ifdef HAVE_TGETENT
static char *(key_names[]) =
{
-#ifdef FEAT_TERMRESPONSE
+# ifdef FEAT_TERMRESPONSE
// Do this one first, it may cause a screen redraw.
"Co",
-#endif
+# endif
"ku", "kd", "kr", "kl",
"#2", "#4", "%i", "*7",
"k1", "k2", "k3", "k4", "k5", "k6",
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index bb9cdc773..a8a549cbd 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1009,13 +1009,17 @@ func Test_terminal_term_start_empty_command()
call assert_fails(cmd, 'E475:')
let cmd = "call term_start('', {'term_highlight' : []})"
call assert_fails(cmd, 'E475:')
- if has('gui')
+ if has('gui') || has('termguicolors')
let cmd = "call term_start('', {'ansi_colors' : 'abc'})"
call assert_fails(cmd, 'E475:')
let cmd = "call term_start('', {'ansi_colors' : [[]]})"
call assert_fails(cmd, 'E730:')
let cmd = "call term_start('', {'ansi_colors' : repeat(['blue'], 18)})"
- call assert_fails(cmd, 'E475:')
+ if has('gui_running') || has('termguicolors')
+ call assert_fails(cmd, 'E475:')
+ else
+ call assert_fails(cmd, 'E254:')
+ endif
endif
endfunc
@@ -2668,7 +2672,6 @@ endfunc
" Test for passing invalid arguments to terminal functions
func Test_term_func_invalid_arg()
call assert_fails('let b = term_getaltscreen([])', 'E745:')
- call assert_fails('let p = term_getansicolors([])', 'E745:')
call assert_fails('let a = term_getattr(1, [])', 'E730:')
call assert_fails('let c = term_getcursor([])', 'E745:')
call assert_fails('let l = term_getline([], 1)', 'E745:')
@@ -2677,10 +2680,13 @@ func Test_term_func_invalid_arg()
call assert_fails('let s = term_getstatus([])', 'E745:')
call assert_fails('let s = term_scrape([], 1)', 'E745:')
call assert_fails('call term_sendkeys([], "a")', 'E745:')
- call assert_fails('call term_setansicolors([], [])', 'E745:')
call assert_fails('call term_setapi([], "")', 'E745:')
call assert_fails('call term_setrestore([], "")', 'E745:')
call assert_fails('call term_setkill([], "")', 'E745:')
+ if has('gui') || has('termguicolors')
+ call assert_fails('let p = term_getansicolors([])', 'E745:')
+ call assert_fails('call term_setansicolors([], [])', 'E745:')
+ endif
endfunc
" Test for sending various special keycodes to a terminal
diff --git a/src/version.c b/src/version.c
index 543f5a8ee..f2afc0b44 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 816,
+/**/
815,
/**/
814,