diff src/channel.c @ 12309:e1f44e4afe67 v8.0.1034

patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows commit https://github.com/vim/vim/commit/3346cc4ffb459ecddb97a8c19bcc5834afa4dead Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 2 14:54:21 2017 +0200 patch 8.0.1034: sending buffer lines to terminal doesn't work on MS-Windows Problem: Sending buffer lines to terminal doesn't work on MS-Windows. Solution: Send CTRL-D to mark the end of the text. (Yasuhiro Matsumoto, closes #2043) Add the "eof_chars" option.
author Christian Brabandt <cb@256bit.org>
date Sat, 02 Sep 2017 15:00:04 +0200
parents ac8b2f9c1409
children 66fa8eabbd6e
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -1417,6 +1417,13 @@ channel_write_in(channel_T *channel)
     in_part->ch_buf_top = lnum;
     if (lnum > buf->b_ml.ml_line_count || lnum > in_part->ch_buf_bot)
     {
+#if defined(WIN32) && defined(FEAT_TERMINAL)
+	/* Send CTRL-D or "eof_chars" to close stdin on Windows. A console
+	 * application doesn't treat closing stdin like UNIX. */
+	if (channel->ch_job != NULL)
+	    term_send_eof(channel);
+#endif
+
 	/* Writing is done, no longer need the buffer. */
 	in_part->ch_bufref.br_buf = NULL;
 	ch_log(channel, "Finished writing all lines to channel");
@@ -4626,6 +4633,22 @@ get_job_options(typval_T *tv, jobopt_T *
 		    return FAIL;
 		}
 	    }
+	    else if (STRCMP(hi->hi_key, "eof_chars") == 0)
+	    {
+# ifdef WIN3264
+		char_u *p;
+
+		if (!(supported2 & JO2_EOF_CHARS))
+		    break;
+		opt->jo_set2 |= JO2_EOF_CHARS;
+		p = opt->jo_eof_chars = get_tv_string_chk(item);
+		if (p == NULL)
+		{
+		    EMSG2(_(e_invarg2), "term_opencmd");
+		    return FAIL;
+		}
+# endif
+	    }
 	    else if (STRCMP(hi->hi_key, "term_rows") == 0)
 	    {
 		if (!(supported2 & JO2_TERM_ROWS))