From: Abhijit Barik Date: Sun, 6 Apr 2025 14:12:06 +0000 (+0200) Subject: patch 9.1.1281: extra newline output when editing stdin X-Git-Tag: v9.1.1281^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=221927b2bfbd7de1623770bee4f6740356bb6c81;p=thirdparty%2Fvim.git patch 9.1.1281: extra newline output when editing stdin Problem: extra newline output when editing stdin Solution: remove outputting when reading from stdin in non-terminal mode (Abhijit Barik) fixes: #16856 closes: #17047 Co-authored-by: LemonBoy Signed-off-by: Abhijit Barik Signed-off-by: Christian Brabandt --- diff --git a/src/main.c b/src/main.c index f603a52a52..7766946288 100644 --- a/src/main.c +++ b/src/main.c @@ -660,7 +660,7 @@ vim_main2(void) #if defined(UNIX) || defined(VMS) // When switching screens and something caused a message from a vimrc // script, need to output an extra newline on exit. - if ((did_emsg || msg_didout) && *T_TI != NUL) + if ((did_emsg || msg_didout) && *T_TI != NUL && params.edit_type != EDIT_STDIN) newline_on_exit = TRUE; #endif diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index 8052aa883d..03876749f4 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -781,6 +781,68 @@ func Test_progpath() call assert_match('vim\c', v:progname) endfunc +func Test_stdin_no_newline() + CheckScreendump + CheckUnix + CheckExecutable bash + + let $PS1 = 'TEST_PROMPT> ' + let buf = RunVimInTerminal('', #{rows: 20, cmd: 'bash --noprofile --norc'}) + call TermWait(buf, 100) + + " Write input to temp file + call term_sendkeys(buf, "echo hello > temp.txt\") + call TermWait(buf, 200) + + call term_sendkeys(buf, "bash -c '../vim --not-a-term -u NONE -c \":q!\" -' < temp.txt\") + call TermWait(buf, 200) + + " Capture terminal output + let lines = [] + for i in range(1, term_getsize(buf)[0]) + call add(lines, term_getline(buf, i)) + endfor + + " Find the command line in output + let cmd_line = -1 + for i in range(len(lines)) + if lines[i] =~ '.*vim.*--not-a-term.*' + let cmd_line = i + break + endif + endfor + + if cmd_line == -1 + call assert_report('Command line not found in terminal output') + else + let next_line = -1 + for i in range(cmd_line + 1, len(lines)) + if lines[i] =~ '\S' + let next_line = i + break + endif + endfor + + if next_line == -1 + call assert_report('No prompt found after command execution') + else + call assert_equal(cmd_line + 1, next_line, 'Prompt should be on the immediate next line') + call assert_match('.*TEST_PROMPT>.*', lines[next_line], 'Line should contain the prompt PS1') + endif + endif + + " Clean up temp file and exit shell + call term_sendkeys(buf, "rm -f temp.txt\") + call term_sendkeys(buf, "exit\") + call TermWait(buf, 200) + + if job_status(term_getjob(buf)) ==# 'run' + call StopVimInTerminal(buf) + endif + + unlet $PS1 +endfunc + func Test_silent_ex_mode() " must be able to get the output of Vim. CheckUnix diff --git a/src/version.c b/src/version.c index 50743e0519..a900afc7b1 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 */ +/**/ + 1281, /**/ 1280, /**/