patch 9.1.0751: Error callback for term_start() not used
Commit:
https://github.com/vim/vim/commit/b50bc9ad55ecda07d5909e7057a6e777cd7e9b97
Author: Christian Brabandt <[email protected]>
Date: Mon Sep 30 21:29:43 2024 +0200
patch 9.1.0751: Error callback for term_start() not used
Problem: Error callback for term_start() not used
(darkseid-is)
Solution: attach pipe to stderr if an error callback exists
fixes: #15665
closes: #15729
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/os_unix.c b/src/os_unix.c
index e77a4b23c..0aa6f3ca1 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5763,8 +5763,11 @@ mch_job_start(char **argv, job_T *job, jobopt_T
*options, int is_terminal)
goto failed;
}
}
+ // only create a pipe for the error fd, when either a callback has been
setup
+ // or pty is not used (e.g. terminal uses pty by default)
else if (!use_out_for_err && !use_null_for_err
- && pty_master_fd < 0 && pipe(fd_err) < 0)
+ && (pty_master_fd < 0 || (options->jo_set & JO_ERR_CALLBACK))
+ && pipe(fd_err) < 0)
goto failed;
if (!use_null_for_in || !use_null_for_out || !use_null_for_err)
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 5761f213c..4215a5874 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -2765,4 +2765,42 @@ func Test_channel_lsp_mode()
call RunServer('test_channel_lsp.py', 'LspTests', [])
endfunc
+func Test_error_callback_terminal()
+ CheckUnix
+ CheckFeature terminal
+ let g:out = ''
+ let g:error = ''
+
+ func! s:Out(channel, msg)
+ let g:out .= string(a:msg)
+ endfunc
+
+ func! s:Err(channel, msg)
+ let g:error .= string(a:msg)
+ endfunc
+
+ let buf = term_start(['sh'], #{term_finish: 'close', out_cb: 's:Out',
err_cb: 's:Err', err_io: 'pipe'})
+ let job = term_getjob(buf)
+ let dict = job_info(job).channel->ch_info()
+
+ call assert_true(dict.id != 0)
+ call assert_equal('open', dict.status)
+ call assert_equal('open', dict.out_status)
+ call assert_equal('RAW', dict.out_mode)
+ call assert_equal('buffer', dict.out_io)
+ call assert_equal('open', dict.err_status)
+ call assert_equal('RAW', dict.err_mode)
+ call assert_equal('pipe', dict.err_io)
+ call term_sendkeys(buf, "XXXX\<cr>")
+ call term_wait(buf)
+ call term_sendkeys(buf, "exit\<cr>")
+ call term_wait(buf)
+ call assert_match('XXX.*exit', g:out)
+ call assert_match('sh:.*XXXX:.*not found', g:error)
+
+ delfunc s:Out
+ delfunc s:Err
+ unlet! g:out g:error
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 7725549b1..c6651c720 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 751,
/**/
750,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/E1svMKM-002fEE-P0%40256bit.org.