summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-05 16:33:56 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-05 16:33:56 +0200
commit35422f45ba01806d357994f18cb9af64980c67e6 (patch)
tree1fbcc82b2d890811a245e9b0323284edc547824a /src
parentd53109886bc9c4fa7a9c9a402c90fe349b2dd7ac (diff)
downloadvim-git-35422f45ba01806d357994f18cb9af64980c67e6.tar.gz
patch 8.0.0867: job and channel in a dict value not quotedv8.0.0867
Problem: When using a job or channel value as a dict value, when turning it into a string the quotes are missing. Solution: Add quotes to the job and channel values. (Yasuhiro Matsumoto, closes #1930)
Diffstat (limited to 'src')
-rw-r--r--src/eval.c23
-rw-r--r--src/list.c2
-rw-r--r--src/testdir/test_terminal.vim3
-rw-r--r--src/version.c2
4 files changed, 23 insertions, 7 deletions
diff --git a/src/eval.c b/src/eval.c
index c35def0b2..b8e606443 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -5683,9 +5683,9 @@ get_var_special_name(int nr)
* If the memory is allocated "tofree" is set to it, otherwise NULL.
* "numbuf" is used for a number.
* When "copyID" is not NULL replace recursive lists and dicts with "...".
- * When both "echo_style" and "dict_val" are FALSE, put quotes around stings as
- * "string()", otherwise does not put quotes around strings, as ":echo"
- * displays values.
+ * When both "echo_style" and "composite_val" are FALSE, put quotes around
+ * stings as "string()", otherwise does not put quotes around strings, as
+ * ":echo" displays values.
* When "restore_copyID" is FALSE, repeated items in dictionaries and lists
* are replaced with "...".
* May return NULL.
@@ -5698,7 +5698,7 @@ echo_string_core(
int copyID,
int echo_style,
int restore_copyID,
- int dict_val)
+ int composite_val)
{
static int recurse = 0;
char_u *r = NULL;
@@ -5721,10 +5721,12 @@ echo_string_core(
switch (tv->v_type)
{
case VAR_STRING:
- if (echo_style && !dict_val)
+ if (echo_style && !composite_val)
{
*tofree = NULL;
- r = get_tv_string_buf(tv, numbuf);
+ r = tv->vval.v_string;
+ if (r == NULL)
+ r = (char_u *)"";
}
else
{
@@ -5841,10 +5843,19 @@ echo_string_core(
case VAR_NUMBER:
case VAR_UNKNOWN:
+ *tofree = NULL;
+ r = get_tv_string_buf(tv, numbuf);
+ break;
+
case VAR_JOB:
case VAR_CHANNEL:
*tofree = NULL;
r = get_tv_string_buf(tv, numbuf);
+ if (composite_val)
+ {
+ *tofree = string_quote(r, FALSE);
+ r = *tofree;
+ }
break;
case VAR_FLOAT:
diff --git a/src/list.c b/src/list.c
index 2fccbae76..b593f7171 100644
--- a/src/list.c
+++ b/src/list.c
@@ -740,7 +740,7 @@ list_join_inner(
for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
{
s = echo_string_core(&item->li_tv, &tofree, numbuf, copyID,
- echo_style, restore_copyID, FALSE);
+ echo_style, restore_copyID, !echo_style);
if (s == NULL)
return FAIL;
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index 98bc75843..8c14fa4d0 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -18,6 +18,9 @@ func Run_shell_in_terminal()
let g:job = term_getjob(buf)
call assert_equal(v:t_job, type(g:job))
+ let string = string({'job': term_getjob(buf)})
+ call assert_match("{'job': 'process \\d\\+ run'}", string)
+
return buf
endfunc
diff --git a/src/version.c b/src/version.c
index 3595c1af5..d3b3215fc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 867,
+/**/
866,
/**/
865,