comparison src/channel.c @ 8291:ac0c43e7af20 v7.4.1438

commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 27 21:10:09 2016 +0100 patch 7.4.1438 Problem: Can't get buffer number of a channel. Solution: Add ch_getbufnr().
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Feb 2016 21:15:04 +0100
parents 108d30ed34ba
children 4929eca308b7
comparison
equal deleted inserted replaced
8290:285c4ec936b5 8291:ac0c43e7af20
785 * Find a buffer matching "name" or create a new one. 785 * Find a buffer matching "name" or create a new one.
786 */ 786 */
787 static buf_T * 787 static buf_T *
788 find_buffer(char_u *name) 788 find_buffer(char_u *name)
789 { 789 {
790 buf_T *buf = buflist_findname(name); 790 buf_T *buf = NULL;
791 buf_T *save_curbuf = curbuf; 791 buf_T *save_curbuf = curbuf;
792 792
793 if (name != NULL && *name != NUL)
794 buf = buflist_findname(name);
793 if (buf == NULL) 795 if (buf == NULL)
794 { 796 {
795 buf = buflist_new(name, NULL, (linenr_T)0, BLN_LISTED); 797 buf = buflist_new(name == NULL ? (char_u *)"" : name,
798 NULL, (linenr_T)0, BLN_LISTED);
796 buf_copy_options(buf, BCO_ENTER); 799 buf_copy_options(buf, BCO_ENTER);
797 #ifdef FEAT_QUICKFIX 800 #ifdef FEAT_QUICKFIX
798 clear_string_option(&buf->b_p_bt); 801 clear_string_option(&buf->b_p_bt);
799 buf->b_p_bt = vim_strsave((char_u *)"nofile"); 802 buf->b_p_bt = vim_strsave((char_u *)"nofile");
800 clear_string_option(&buf->b_p_bh); 803 clear_string_option(&buf->b_p_bh);
878 { 881 {
879 /* writing output to a buffer. Force mode to NL. */ 882 /* writing output to a buffer. Force mode to NL. */
880 channel->ch_part[PART_OUT].ch_mode = MODE_NL; 883 channel->ch_part[PART_OUT].ch_mode = MODE_NL;
881 channel->ch_part[PART_OUT].ch_buffer = 884 channel->ch_part[PART_OUT].ch_buffer =
882 find_buffer(opt->jo_io_name[PART_OUT]); 885 find_buffer(opt->jo_io_name[PART_OUT]);
883 ch_logs(channel, "writing to buffer %s", 886 ch_logs(channel, "writing to buffer '%s'",
884 (char *)channel->ch_part[PART_OUT].ch_buffer->b_ffname); 887 (char *)channel->ch_part[PART_OUT].ch_buffer->b_ffname);
885 } 888 }
886 } 889 }
887 890
888 /* 891 /*
1355 1358
1356 if (channel->ch_part[part].ch_callback != NULL) 1359 if (channel->ch_part[part].ch_callback != NULL)
1357 callback = channel->ch_part[part].ch_callback; 1360 callback = channel->ch_part[part].ch_callback;
1358 else 1361 else
1359 callback = channel->ch_callback; 1362 callback = channel->ch_callback;
1363
1360 buffer = channel->ch_part[part].ch_buffer; 1364 buffer = channel->ch_part[part].ch_buffer;
1365 if (buffer != NULL && !buf_valid(buffer))
1366 {
1367 /* buffer was wiped out */
1368 channel->ch_part[part].ch_buffer = NULL;
1369 buffer = NULL;
1370 }
1361 1371
1362 if (ch_mode == MODE_JSON || ch_mode == MODE_JS) 1372 if (ch_mode == MODE_JSON || ch_mode == MODE_JS)
1363 { 1373 {
1364 listitem_T *item; 1374 listitem_T *item;
1365 int argc = 0; 1375 int argc = 0;