From 53f1673cd909eb1c809c6a9086e3d104a0df9bed Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Sep 2016 20:46:39 +0200 Subject: [PATCH 1/2] patch 7.4.2343 Problem: Too many old file tests. Solution: Turn several into new style tests. (Yegappan Lakshmanan) --- src/Makefile | 5 +++- src/testdir/Make_all.mak | 10 +++---- src/testdir/test101.in | 48 -------------------------------- src/testdir/test101.ok | 12 -------- src/testdir/test18.in | 16 ----------- src/testdir/test18.ok | 4 --- src/testdir/test2.in | 29 ------------------- src/testdir/test2.ok | 4 --- src/testdir/test21.in | 19 ------------- src/testdir/test21.ok | 2 -- src/testdir/test6.in | 24 ---------------- src/testdir/test6.ok | 18 ------------ src/testdir/test_arglist.vim | 29 +++++++++++++++++++ src/testdir/test_charsearch.vim | 4 +-- src/testdir/test_fnameescape.vim | 2 +- src/testdir/test_gf.vim | 33 ++++++++++++++++++++++ src/testdir/test_hlsearch.vim | 34 ++++++++++++++++++++++ src/testdir/test_smartindent.vim | 14 ++++++++++ src/testdir/test_tagjump.vim | 30 ++++++++++++++++++++ src/version.c | 2 ++ 20 files changed, 153 insertions(+), 186 deletions(-) delete mode 100644 src/testdir/test101.in delete mode 100644 src/testdir/test101.ok delete mode 100644 src/testdir/test18.in delete mode 100644 src/testdir/test18.ok delete mode 100644 src/testdir/test2.in delete mode 100644 src/testdir/test2.ok delete mode 100644 src/testdir/test21.in delete mode 100644 src/testdir/test21.ok delete mode 100644 src/testdir/test6.in delete mode 100644 src/testdir/test6.ok create mode 100644 src/testdir/test_gf.vim create mode 100644 src/testdir/test_hlsearch.vim create mode 100644 src/testdir/test_smartindent.vim diff --git a/src/Makefile b/src/Makefile index a56aa04e6c..79d7a9c4ad 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2041,7 +2041,7 @@ test1 \ test_search_mbyte \ test_utf8 \ test_wordcount \ - test2 test3 test4 test5 test6 test7 test8 test9 \ + test3 test4 test5 test6 test7 test8 test9 \ test11 test12 test14 test15 test17 test18 test19 \ test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \ test30 test31 test32 test33 test34 test36 test37 test38 test39 \ @@ -2085,12 +2085,14 @@ test_arglist \ test_fnameescape \ test_fnamemodify \ test_glob2regpat \ + test_gf \ test_gn \ test_goto \ test_gui \ test_hardcopy \ test_help_tagjump \ test_history \ + test_hlsearch \ test_increment \ test_increment_dbcs \ test_job_fails \ @@ -2128,6 +2130,7 @@ test_arglist \ test_signs \ test_sort \ test_source_utf8 \ + test_smartindent \ test_startup \ test_startup_utf8 \ test_stat \ diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 5a7099337d..65ad3ee12f 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -13,16 +13,13 @@ SCRIPTS_ALL = \ test3.out \ test4.out \ test5.out \ - test6.out \ test7.out \ test8.out \ test9.out \ test14.out \ test15.out \ - test18.out \ test19.out \ test20.out \ - test21.out \ test22.out \ test23.out \ test24.out \ @@ -74,7 +71,6 @@ SCRIPTS_ALL = \ test95.out \ test98.out \ test99.out \ - test101.out \ test103.out \ test104.out \ test107.out \ @@ -109,7 +105,6 @@ SCRIPTS_MORE1 = \ # Tests that run on most systems, but not on Amiga and DOS/Windows. SCRIPTS_MORE2 = \ - test2.out \ test12.out \ test25.out \ test49.out \ @@ -147,7 +142,7 @@ SCRIPTS_GUI = # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = test_arglist.res \ test_assert.res \ - test_autochdir \ + test_autochdir.res \ test_backspace_opt.res \ test_bufwintabinfo.res \ test_cdo.res \ @@ -159,10 +154,12 @@ NEW_TESTS = test_arglist.res \ test_digraph.res \ test_farsi.res \ test_fnameescape.res \ + test_gf.res \ test_gn.res \ test_gui.res \ test_hardcopy.res \ test_history.res \ + test_hlsearch.res \ test_increment.res \ test_increment_dbcs.res \ test_job_fails.res \ @@ -180,6 +177,7 @@ NEW_TESTS = test_arglist.res \ test_ruby.res \ test_search.res \ test_signs.res \ + test_smartindent.res \ test_startup.res \ test_startup_utf8.res \ test_stat.res \ diff --git a/src/testdir/test101.in b/src/testdir/test101.in deleted file mode 100644 index 31fc334393..0000000000 --- a/src/testdir/test101.in +++ /dev/null @@ -1,48 +0,0 @@ -Test for v:hlsearch vim: set ft=vim : - -STARTTEST -:" Last abc: Q -:so small.vim -:new -:call setline(1, repeat(['aaa'], 10)) -:set hlsearch nolazyredraw -:let r=[] -:command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch]) -/aaa -:AddR -:nohlsearch -:AddR -:let v:hlsearch=1 -:AddR -:let v:hlsearch=0 -:AddR -:set hlsearch -:AddR -:let v:hlsearch=0 -:AddR -n:AddR -:let v:hlsearch=0 -:AddR -/ -:AddR -:set nohls -/ -:AddR -:let r1=r[0][0] -:" I guess it is not guaranteed that screenattr outputs always the same character -:call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")') -:try -: let v:hlsearch=[] -:catch -: call add(r, matchstr(v:exception,'^Vim(let):E\d\+:')) -:endtry -:bwipeout! -:$put=r -:call garbagecollect(1) -:" -:/^start:/,$wq! test.out -:" vim: et ts=4 isk-=\: -:call getchar() -ENDTEST - -start: diff --git a/src/testdir/test101.ok b/src/testdir/test101.ok deleted file mode 100644 index 86aa73b205..0000000000 --- a/src/testdir/test101.ok +++ /dev/null @@ -1,12 +0,0 @@ -start: -1:highlighted -0:not highlighted -1:highlighted -0:not highlighted -1:highlighted -0:not highlighted -1:highlighted -0:not highlighted -1:highlighted -0:not highlighted -Vim(let):E745: diff --git a/src/testdir/test18.in b/src/testdir/test18.in deleted file mode 100644 index 9bfd922344..0000000000 --- a/src/testdir/test18.in +++ /dev/null @@ -1,16 +0,0 @@ -Tests for not doing smart indenting when it isn't set. - -STARTTEST -:so small.vim -:set nocin nosi ai -/some -2cc#test -:?start?,$w! test.out -:qa! -ENDTEST - -start text - some test text - test text -test text - test text diff --git a/src/testdir/test18.ok b/src/testdir/test18.ok deleted file mode 100644 index e719713785..0000000000 --- a/src/testdir/test18.ok +++ /dev/null @@ -1,4 +0,0 @@ -start text - #test -test text - test text diff --git a/src/testdir/test2.in b/src/testdir/test2.in deleted file mode 100644 index b7b5a51066..0000000000 --- a/src/testdir/test2.in +++ /dev/null @@ -1,29 +0,0 @@ - -This is a test if a URL is recognized by "gf", with the cursor before and -after the "://". Also test ":\\". - -STARTTEST -:so small.vim -/^first -/tmp -:call append(0, expand("")) -/^second -/URL -:call append(1, expand("")) -:if has("ebcdic") -: set isf=@,240-249,/,.,-,_,+,,,$,:,~,\ -:else -: set isf=@,48-57,/,.,-,_,+,,,$,:,~,\ -:endif -/^third -/name -:call append(2, expand("")) -/^fourth -/URL -:call append(3, expand("")) -5GdG:wq! test.out -ENDTEST -first test for URL://machine.name/tmp/vimtest2a and other text -second test for URL://machine.name/tmp/vimtest2b. And other text -third test for URL:\\machine.name\vimtest2c and other text -fourth test for URL:\\machine.name\tmp\vimtest2d, and other text diff --git a/src/testdir/test2.ok b/src/testdir/test2.ok deleted file mode 100644 index 32978825f8..0000000000 --- a/src/testdir/test2.ok +++ /dev/null @@ -1,4 +0,0 @@ -URL://machine.name/tmp/vimtest2a -URL://machine.name/tmp/vimtest2b -URL:\\machine.name\vimtest2c -URL:\\machine.name\tmp\vimtest2d diff --git a/src/testdir/test21.in b/src/testdir/test21.in deleted file mode 100644 index 491b9f7404..0000000000 --- a/src/testdir/test21.in +++ /dev/null @@ -1,19 +0,0 @@ -Tests for [ CTRL-I with a count and CTRL-W CTRL-I with a count - -STARTTEST -:so small.vim -/start -6[ :.w! test.out -?start here -6 :.w >>test.out -:qa! -ENDTEST - -#include test21.in - -/* test text test tex start here - some text - test text - start OK if found this line - start found wrong line -test text diff --git a/src/testdir/test21.ok b/src/testdir/test21.ok deleted file mode 100644 index d9f1b759ce..0000000000 --- a/src/testdir/test21.ok +++ /dev/null @@ -1,2 +0,0 @@ - start OK if found this line - start OK if found this line diff --git a/src/testdir/test6.in b/src/testdir/test6.in deleted file mode 100644 index 1ebbe2fa51..0000000000 --- a/src/testdir/test6.in +++ /dev/null @@ -1,24 +0,0 @@ -Test for autocommand that redefines the argument list, when doing ":all". - -STARTTEST -:so small.vim -:au BufReadPost Xxx2 next Xxx2 Xxx1 -/^start of -A1:.,/end of/w! Xxx1 " write test file Xxx1 -$r2:.,/end of/w! Xxx2 " write test file Xxx2 -$r3:.,/end of/w! Xxx3 " write test file Xxx3 -:next! Xxx1 Xxx2 Xxx3 " redefine arglist; go to Xxx1 -:all " open window for all args -:w! test.out " Write contents of Xxx1 -:w >>test.out " Append contents of last window (Xxx1) -:rew " should now be in Xxx2 -:w >>test.out " Append contents of Xxx2 -:qa! -ENDTEST - -start of test file Xxx - this is a test - this is a test - this is a test - this is a test -end of test file Xxx diff --git a/src/testdir/test6.ok b/src/testdir/test6.ok deleted file mode 100644 index b6b0c93e4e..0000000000 --- a/src/testdir/test6.ok +++ /dev/null @@ -1,18 +0,0 @@ -start of test file Xxx1 - this is a test - this is a test - this is a test - this is a test -end of test file Xxx -start of test file Xxx1 - this is a test - this is a test - this is a test - this is a test -end of test file Xxx -start of test file Xxx2 - this is a test - this is a test - this is a test - this is a test -end of test file Xxx diff --git a/src/testdir/test_arglist.vim b/src/testdir/test_arglist.vim index 4244344270..0caead8482 100644 --- a/src/testdir/test_arglist.vim +++ b/src/testdir/test_arglist.vim @@ -287,3 +287,32 @@ function Test_argpos() call assert_equal(0, argidx()) %argd endfunction + +" Test for autocommand that redefines the argument list, when doing ":all". +function Test_arglist_autocmd() + autocmd BufReadPost Xxx2 next Xxx2 Xxx1 + call writefile(['test file Xxx1'], 'Xxx1') + call writefile(['test file Xxx2'], 'Xxx2') + call writefile(['test file Xxx3'], 'Xxx3') + + new + " redefine arglist; go to Xxx1 + next! Xxx1 Xxx2 Xxx3 + " open window for all args + all + call assert_equal('test file Xxx1', getline(1)) + wincmd w + wincmd w + call assert_equal('test file Xxx1', getline(1)) + " should now be in Xxx2 + rewind + call assert_equal('test file Xxx2', getline(1)) + + autocmd! BufReadPost Xxx2 + enew! | only + call delete('Xxx1') + call delete('Xxx2') + call delete('Xxx3') + argdelete Xxx* + bwipe! Xxx1 Xxx2 Xxx3 +endfunction diff --git a/src/testdir/test_charsearch.vim b/src/testdir/test_charsearch.vim index 115659a013..8b313b5a35 100644 --- a/src/testdir/test_charsearch.vim +++ b/src/testdir/test_charsearch.vim @@ -2,8 +2,8 @@ function! Test_charsearch() enew! call append(0, ['Xabcdefghijkemnopqretuvwxyz', - \ 'Yabcdefghijkemnopqretuvwxyz', - \ 'Zabcdefghijkemnokqretkvwxyz']) + \ 'Yabcdefghijkemnopqretuvwxyz', + \ 'Zabcdefghijkemnokqretkvwxyz']) " check that "fe" and ";" work 1 normal! ylfep;;p,,p diff --git a/src/testdir/test_fnameescape.vim b/src/testdir/test_fnameescape.vim index ce2cd3f7a6..cdff0dfbd9 100644 --- a/src/testdir/test_fnameescape.vim +++ b/src/testdir/test_fnameescape.vim @@ -6,7 +6,7 @@ function! Test_fnameescape() try exe "w! " . fnameescape(fname) let status = v:true - endtry + endtry call assert_true(status, "Space") call delete(fname) diff --git a/src/testdir/test_gf.vim b/src/testdir/test_gf.vim new file mode 100644 index 0000000000..c4aa6f9218 --- /dev/null +++ b/src/testdir/test_gf.vim @@ -0,0 +1,33 @@ + +" This is a test if a URL is recognized by "gf", with the cursor before and +" after the "://". Also test ":\\". +function! Test_gf_url() + enew! + call append(0, [ + \ "first test for URL://machine.name/tmp/vimtest2a and other text", + \ "second test for URL://machine.name/tmp/vimtest2b. And other text", + \ "third test for URL:\\\\machine.name\\vimtest2c and other text", + \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text" + \ ]) + call cursor(1,1) + call search("^first") + call search("tmp") + call assert_equal("URL://machine.name/tmp/vimtest2a", expand("")) + call search("^second") + call search("URL") + call assert_equal("URL://machine.name/tmp/vimtest2b", expand("")) + if has("ebcdic") + set isf=@,240-249,/,.,-,_,+,,,$,:,~,\ + else + set isf=@,48-57,/,.,-,_,+,,,$,:,~,\ + endif + call search("^third") + call search("name") + call assert_equal("URL:\\\\machine.name\\vimtest2c", expand("")) + call search("^fourth") + call search("URL") + call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("")) + + set isf&vim + enew! +endfunction diff --git a/src/testdir/test_hlsearch.vim b/src/testdir/test_hlsearch.vim new file mode 100644 index 0000000000..066fdd0250 --- /dev/null +++ b/src/testdir/test_hlsearch.vim @@ -0,0 +1,34 @@ +" Test for v:hlsearch + +function! Test_hlsearch() + new + call setline(1, repeat(['aaa'], 10)) + set hlsearch nolazyredraw + let r=[] + " redraw is needed to make hlsearch highlight the matches + exe "normal! /aaa\" | redraw + let r1 = screenattr(1, 1) + nohlsearch | redraw + call assert_notequal(r1, screenattr(1,1)) + let v:hlsearch=1 | redraw + call assert_equal(r1, screenattr(1,1)) + let v:hlsearch=0 | redraw + call assert_notequal(r1, screenattr(1,1)) + set hlsearch | redraw + call assert_equal(r1, screenattr(1,1)) + let v:hlsearch=0 | redraw + call assert_notequal(r1, screenattr(1,1)) + exe "normal! n" | redraw + call assert_equal(r1, screenattr(1,1)) + let v:hlsearch=0 | redraw + call assert_notequal(r1, screenattr(1,1)) + exe "normal! /\" | redraw + call assert_equal(r1, screenattr(1,1)) + set nohls + exe "normal! /\" | redraw + call assert_notequal(r1, screenattr(1,1)) + call assert_fails('let v:hlsearch=[]', 'E745') + call garbagecollect(1) + call getchar(1) + enew! +endfunction diff --git a/src/testdir/test_smartindent.vim b/src/testdir/test_smartindent.vim new file mode 100644 index 0000000000..d00eac9798 --- /dev/null +++ b/src/testdir/test_smartindent.vim @@ -0,0 +1,14 @@ + +" Tests for not doing smart indenting when it isn't set. +function! Test_nosmartindent() + new + call append(0, [" some test text", + \ " test text", + \ "test text", + \ " test text"]) + set nocindent nosmartindent autoindent + exe "normal! gg/some\" + exe "normal! 2cc#test\" + call assert_equal(" #test", getline(1)) + enew! | close +endfunction diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim index 678ad0ada8..11ec144f63 100644 --- a/src/testdir/test_tagjump.vim +++ b/src/testdir/test_tagjump.vim @@ -23,4 +23,34 @@ func Test_cancel_ptjump() quit endfunc +" Tests for [ CTRL-I and CTRL-W CTRL-I commands +function Test_keyword_jump() + call writefile(["#include Xinclude", "", + \ "", + \ "/* test text test tex start here", + \ " some text", + \ " test text", + \ " start OK if found this line", + \ " start found wrong line", + \ "test text"], 'Xtestfile') + call writefile(["/* test text test tex start here", + \ " some text", + \ " test text", + \ " start OK if found this line", + \ " start found wrong line", + \ "test text"], 'Xinclude') + new Xtestfile + call cursor(1,1) + call search("start") + exe "normal! 5[\" + call assert_equal(" start OK if found this line", getline('.')) + call cursor(1,1) + call search("start") + exe "normal! 5\\" + call assert_equal(" start OK if found this line", getline('.')) + enew! | only + call delete('Xtestfile') + call delete('Xinclude') +endfunction + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index c870edd7e5..726089b880 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2343, /**/ 2342, /**/ From 169ebb080454357279ad5ad21ac532deaec605e8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Sep 2016 23:32:23 +0200 Subject: [PATCH 2/2] patch 7.4.2344 Problem: The "Reading from channel output..." message can be unwanted. Appending to a buffer leaves an empty first line behind. Solution: Add the "out_msg" and "err_msg" options. Writing the first line overwrites the first, empty line. --- runtime/doc/channel.txt | 16 +++++++++-- src/channel.c | 41 ++++++++++++++++++++++---- src/structs.h | 6 ++++ src/testdir/test_channel.vim | 56 ++++++++++++++++++++++++------------ src/version.c | 2 ++ 5 files changed, 95 insertions(+), 26 deletions(-) diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index 1f23042aef..5a656977dc 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -1,4 +1,4 @@ -*channel.txt* For Vim version 7.4. Last change: 2016 Sep 01 +*channel.txt* For Vim version 7.4. Last change: 2016 Sep 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -646,6 +646,8 @@ See |job_setoptions()| and |ch_setoptions()|. "out_buf": number the number of the buffer to write to "out_modifiable": 0 when writing to a buffer, 'modifiable' will be off (see below) +"out_msg": 0 when writing to a new buffer, the first line will be + set to "Reading from channel output..." *job-err_io* *err_name* *err_buf* "err_io": "out" stderr messages to go to stdout @@ -657,6 +659,8 @@ See |job_setoptions()| and |ch_setoptions()|. "err_buf": number the number of the buffer to write to "err_modifiable": 0 when writing to a buffer, 'modifiable' will be off (see below) +"err_msg": 0 when writing to a new buffer, the first line will be + set to "Reading from channel error..." "block_write": number only for testing: pretend every other write to stdin will block @@ -686,8 +690,16 @@ buffer number. For a new buffer 'buftype' is set to "nofile" and 'bufhidden' to "hide". If you prefer other settings, create the buffer first and pass the buffer number. - + *out_modifiable* *err_modifiable* The "out_modifiable" and "err_modifiable" options can be used to set the +'modifiable' option off, or write to a buffer that has 'modifiable' off. That +means that lines will be appended to the buffer, but the user can't easily +change the buffer. + *out_msg* *err_msg* +The "out_msg" option can be used to specify whether a new buffer will have the +first line set to "Reading from channel output...". The default is to add the +message. "err_msg" does the same for channel error. + 'modifiable' option off, or write to a buffer that has 'modifiable' off. That means that lines will be appended to the buffer, but the user can't easily change the buffer. diff --git a/src/channel.c b/src/channel.c index 10ed42e6b7..f4d1e95b08 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1079,7 +1079,7 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *options) * Returns NULL if there is something very wrong (error already reported). */ static buf_T * -find_buffer(char_u *name, int err) +find_buffer(char_u *name, int err, int msg) { buf_T *buf = NULL; buf_T *save_curbuf = curbuf; @@ -1104,7 +1104,8 @@ find_buffer(char_u *name, int err) #endif if (curbuf->b_ml.ml_mfp == NULL) ml_open(curbuf); - ml_replace(1, (char_u *)(err ? "Reading from channel error..." + if (msg) + ml_replace(1, (char_u *)(err ? "Reading from channel error..." : "Reading from channel output..."), TRUE); changed_bytes(1, 0); curbuf = save_curbuf; @@ -1196,7 +1197,11 @@ channel_set_options(channel_T *channel, jobopt_T *opt) } else { - buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE); + int msg = TRUE; + + if (opt->jo_set2 & JO2_OUT_MSG) + msg = opt->jo_message[PART_OUT]; + buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg); } if (buf != NULL) { @@ -1235,7 +1240,13 @@ channel_set_options(channel_T *channel, jobopt_T *opt) EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]); } else - buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE); + { + int msg = TRUE; + + if (opt->jo_set2 & JO2_ERR_MSG) + msg = opt->jo_message[PART_ERR]; + buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg); + } if (buf != NULL) { if (opt->jo_set & JO_ERR_MODIFIABLE) @@ -2227,6 +2238,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, int part) int save_write_to = buffer->b_write_to_channel; chanpart_T *ch_part = &channel->ch_part[part]; int save_p_ma = buffer->b_p_ma; + int empty = (buffer->b_ml.ml_flags & ML_EMPTY); if (!buffer->b_p_ma && !ch_part->ch_nomodifiable) { @@ -2253,9 +2265,16 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, int part) curbuf = buffer; u_sync(TRUE); /* ignore undo failure, undo is not very useful here */ - ignored = u_save(lnum, lnum + 1); + ignored = u_save(lnum, lnum + 1 + (empty ? 1 : 0)); - ml_append(lnum, msg, 0, FALSE); + if (empty) + { + /* The buffer is empty, replace the first (dummy) line. */ + ml_replace(lnum, msg, TRUE); + lnum = 0; + } + else + ml_append(lnum, msg, 0, FALSE); appended_lines_mark(lnum, 1L); curbuf = save_curbuf; if (ch_part->ch_nomodifiable) @@ -4083,6 +4102,16 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported) opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT); opt->jo_modifiable[part] = get_tv_number(item); } + else if (STRCMP(hi->hi_key, "out_msg") == 0 + || STRCMP(hi->hi_key, "err_msg") == 0) + { + part = part_from_char(*hi->hi_key); + + if (!(supported & JO_OUT_IO)) + break; + opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT); + opt->jo_message[part] = get_tv_number(item); + } else if (STRCMP(hi->hi_key, "in_top") == 0 || STRCMP(hi->hi_key, "in_bot") == 0) { diff --git a/src/structs.h b/src/structs.h index 8bdd3c9cb3..2a4284ac57 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1634,6 +1634,10 @@ struct channel_S { #define JO_ERR_MODIFIABLE 0x40000000 /* "err_modifiable" (JO_OUT_ << 1) */ #define JO_ALL 0x7fffffff +#define JO2_OUT_MSG 0x0001 /* "out_msg" */ +#define JO2_ERR_MSG 0x0002 /* "err_msg" (JO_OUT_ << 1) */ +#define JO2_ALL 0x0003 + #define JO_MODE_ALL (JO_MODE + JO_IN_MODE + JO_OUT_MODE + JO_ERR_MODE) #define JO_CB_ALL \ (JO_CALLBACK + JO_OUT_CALLBACK + JO_ERR_CALLBACK + JO_CLOSE_CALLBACK) @@ -1645,6 +1649,7 @@ struct channel_S { typedef struct { int jo_set; /* JO_ bits for values that were set */ + int jo_set2; /* JO2_ bits for values that were set */ ch_mode_T jo_mode; ch_mode_T jo_in_mode; @@ -1656,6 +1661,7 @@ typedef struct char_u *jo_io_name[4]; /* not allocated! */ int jo_io_buf[4]; int jo_modifiable[4]; + int jo_message[4]; channel_T *jo_channel; linenr_T jo_in_top; diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 4b511118ad..f8252f1a3c 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -638,21 +638,27 @@ func BufCloseCb(ch) let g:Ch_bufClosed = 'yes' endfunc -func Run_test_pipe_to_buffer(use_name, nomod) +func Run_test_pipe_to_buffer(use_name, nomod, do_msg) if !has('job') return endif call ch_log('Test_pipe_to_buffer()') let g:Ch_bufClosed = 'no' let options = {'out_io': 'buffer', 'close_cb': 'BufCloseCb'} + let expected = ['', 'line one', 'line two', 'this', 'AND this', 'Goodbye!'] if a:use_name let options['out_name'] = 'pipe-output' - let firstline = 'Reading from channel output...' + if a:do_msg + let expected[0] = 'Reading from channel output...' + else + let options['out_msg'] = 0 + call remove(expected, 0) + endif else sp pipe-output let options['out_buf'] = bufnr('%') quit - let firstline = '' + call remove(expected, 0) endif if a:nomod let options['out_modifiable'] = 0 @@ -667,7 +673,7 @@ func Run_test_pipe_to_buffer(use_name, nomod) call ch_sendraw(handle, "quit\n") sp pipe-output call WaitFor('line("$") >= 6 && g:Ch_bufClosed == "yes"') - call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this', 'Goodbye!'], getline(1, '$')) + call assert_equal(expected, getline(1, '$')) if a:nomod call assert_equal(0, &modifiable) else @@ -681,31 +687,41 @@ func Run_test_pipe_to_buffer(use_name, nomod) endfunc func Test_pipe_to_buffer_name() - call Run_test_pipe_to_buffer(1, 0) + call Run_test_pipe_to_buffer(1, 0, 1) endfunc func Test_pipe_to_buffer_nr() - call Run_test_pipe_to_buffer(0, 0) + call Run_test_pipe_to_buffer(0, 0, 1) endfunc func Test_pipe_to_buffer_name_nomod() - call Run_test_pipe_to_buffer(1, 1) + call Run_test_pipe_to_buffer(1, 1, 1) endfunc -func Run_test_pipe_err_to_buffer(use_name, nomod) +func Test_pipe_to_buffer_name_nomsg() + call Run_test_pipe_to_buffer(1, 0, 1) +endfunc + +func Run_test_pipe_err_to_buffer(use_name, nomod, do_msg) if !has('job') return endif call ch_log('Test_pipe_err_to_buffer()') let options = {'err_io': 'buffer'} + let expected = ['', 'line one', 'line two', 'this', 'AND this'] if a:use_name let options['err_name'] = 'pipe-err' - let firstline = 'Reading from channel error...' + if a:do_msg + let expected[0] = 'Reading from channel error...' + else + let options['err_msg'] = 0 + call remove(expected, 0) + endif else sp pipe-err let options['err_buf'] = bufnr('%') quit - let firstline = '' + call remove(expected, 0) endif if a:nomod let options['err_modifiable'] = 0 @@ -720,7 +736,7 @@ func Run_test_pipe_err_to_buffer(use_name, nomod) call ch_sendraw(handle, "quit\n") sp pipe-err call WaitFor('line("$") >= 5') - call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this'], getline(1, '$')) + call assert_equal(expected, getline(1, '$')) if a:nomod call assert_equal(0, &modifiable) else @@ -733,15 +749,19 @@ func Run_test_pipe_err_to_buffer(use_name, nomod) endfunc func Test_pipe_err_to_buffer_name() - call Run_test_pipe_err_to_buffer(1, 0) + call Run_test_pipe_err_to_buffer(1, 0, 1) endfunc func Test_pipe_err_to_buffer_nr() - call Run_test_pipe_err_to_buffer(0, 0) + call Run_test_pipe_err_to_buffer(0, 0, 1) endfunc func Test_pipe_err_to_buffer_name_nomod() - call Run_test_pipe_err_to_buffer(1, 1) + call Run_test_pipe_err_to_buffer(1, 1, 1) +endfunc + +func Test_pipe_err_to_buffer_name_nomsg() + call Run_test_pipe_err_to_buffer(1, 0, 0) endfunc func Test_pipe_both_to_buffer() @@ -1407,7 +1427,7 @@ func Test_collapse_buffers() 1,$delete call job_start('cat test_channel.vim', {'out_io': 'buffer', 'out_name': 'testout'}) call WaitFor('line("$") > g:linecount') - call assert_inrange(g:linecount + 1, g:linecount + 2, line('$')) + call assert_inrange(g:linecount, g:linecount + 1, line('$')) bwipe! endfunc @@ -1425,9 +1445,9 @@ func Test_raw_passes_nul() 1,$delete call job_start('cat Xtestread', {'out_io': 'buffer', 'out_name': 'testout'}) call WaitFor('line("$") > 2') - call assert_equal("asdf\nasdf", getline(2)) - call assert_equal("xxx\n", getline(3)) - call assert_equal("\nyyy", getline(4)) + call assert_equal("asdf\nasdf", getline(1)) + call assert_equal("xxx\n", getline(2)) + call assert_equal("\nyyy", getline(3)) call delete('Xtestread') bwipe! diff --git a/src/version.c b/src/version.c index 726089b880..634c1285ca 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2344, /**/ 2343, /**/