Skip to content

Commit 7da3460

Browse files
committed
patch 8.0.0829: job running in terminal can't communicate with Vim
Problem: A job running in a terminal window cannot easily communicate with the Vim it is running in. Solution: Pass v:servername in an environment variable. (closes #1908)
1 parent 983b3a5 commit 7da3460

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/os_unix.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4094,6 +4094,9 @@ mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc)
40944094
#endif
40954095

40964096
#if !defined(USE_SYSTEM) || defined(FEAT_JOB_CHANNEL)
4097+
/*
4098+
* Set the environment for a child process.
4099+
*/
40974100
static void
40984101
set_child_environment(long rows, long columns, char *term)
40994102
{
@@ -4105,14 +4108,14 @@ set_child_environment(long rows, long columns, char *term)
41054108
static char envbuf_Lines[20];
41064109
static char envbuf_Columns[20];
41074110
static char envbuf_Colors[20];
4111+
static char envbuf_Servername[60];
41084112
# endif
41094113
long colors =
41104114
# ifdef FEAT_GUI
41114115
gui.in_use ? 256*256*256 :
41124116
# endif
41134117
t_colors;
41144118

4115-
/* Simulate to have a dumb terminal (for now) */
41164119
# ifdef HAVE_SETENV
41174120
setenv("TERM", term, 1);
41184121
sprintf((char *)envbuf, "%ld", rows);
@@ -4123,10 +4126,12 @@ set_child_environment(long rows, long columns, char *term)
41234126
setenv("COLUMNS", (char *)envbuf, 1);
41244127
sprintf((char *)envbuf, "%ld", colors);
41254128
setenv("COLORS", (char *)envbuf, 1);
4129+
setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1);
41264130
# else
41274131
/*
41284132
* Putenv does not copy the string, it has to remain valid.
41294133
* Use a static array to avoid losing allocated memory.
4134+
* This won't work well when running multiple children...
41304135
*/
41314136
vim_snprintf(envbuf_Term, sizeof(envbuf_Term), "TERM=%s", term);
41324137
putenv(envbuf_Term);
@@ -4139,6 +4144,9 @@ set_child_environment(long rows, long columns, char *term)
41394144
putenv(envbuf_Columns);
41404145
vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors);
41414146
putenv(envbuf_Colors);
4147+
vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername),
4148+
"VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName);
4149+
putenv(envbuf_Servername);
41424150
# endif
41434151
}
41444152

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
829,
772774
/**/
773775
828,
774776
/**/

0 commit comments

Comments
 (0)