To: vim_dev@googlegroups.com Subject: Patch 8.2.1654 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1654 Problem: When job writes to hidden buffer current window has display errors. (Johnny McArthur) Solution: Use aucmd_prepbuf() instead of switch_to_win_for_buf(). (closes #6925) Files: src/channel.c *** /tmp/MsQ5IX_channel.c 2020-09-11 11:21:56.706842811 +0200 --- /tmp/6A36FX_channel.c 2020-09-11 11:21:56.706842811 +0200 *************** *** 2619,2627 **** static void append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part) { ! bufref_T save_curbuf = {NULL, 0, 0}; ! win_T *save_curwin = NULL; ! tabpage_T *save_curtab = NULL; linenr_T lnum = buffer->b_ml.ml_line_count; int save_write_to = buffer->b_write_to_channel; chanpart_T *ch_part = &channel->ch_part[part]; --- 2619,2625 ---- static void append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part) { ! aco_save_T aco; linenr_T lnum = buffer->b_ml.ml_line_count; int save_write_to = buffer->b_write_to_channel; chanpart_T *ch_part = &channel->ch_part[part]; *************** *** 2647,2658 **** } // Append to the buffer ! ch_log(channel, "appending line %d to buffer", (int)lnum + 1 - empty); buffer->b_p_ma = TRUE; ! // Save curbuf/curwin/curtab and make "buffer" the current buffer. ! switch_to_win_for_buf(buffer, &save_curwin, &save_curtab, &save_curbuf); u_sync(TRUE); // ignore undo failure, undo is not very useful here --- 2645,2657 ---- } // Append to the buffer ! ch_log(channel, "appending line %d to buffer %s", ! (int)lnum + 1 - empty, buffer->b_fname); buffer->b_p_ma = TRUE; ! // set curbuf to be our buf, temporarily ! aucmd_prepbuf(&aco, buffer); u_sync(TRUE); // ignore undo failure, undo is not very useful here *************** *** 2668,2675 **** ml_append(lnum, msg, 0, FALSE); appended_lines_mark(lnum, 1L); ! // Restore curbuf/curwin/curtab ! restore_win_for_buf(save_curwin, save_curtab, &save_curbuf); if (ch_part->ch_nomodifiable) buffer->b_p_ma = FALSE; --- 2667,2674 ---- ml_append(lnum, msg, 0, FALSE); appended_lines_mark(lnum, 1L); ! // reset notion of buffer ! aucmd_restbuf(&aco); if (ch_part->ch_nomodifiable) buffer->b_p_ma = FALSE; *************** *** 2693,2701 **** // down. If the topline is outdated update it now. if (move_cursor || wp->w_topline > buffer->b_ml.ml_line_count) { if (move_cursor) ++wp->w_cursor.lnum; - save_curwin = curwin; curwin = wp; curbuf = curwin->w_buffer; scroll_cursor_bot(0, FALSE); --- 2692,2701 ---- // down. If the topline is outdated update it now. if (move_cursor || wp->w_topline > buffer->b_ml.ml_line_count) { + win_T *save_curwin = curwin; + if (move_cursor) ++wp->w_cursor.lnum; curwin = wp; curbuf = curwin->w_buffer; scroll_cursor_bot(0, FALSE); *** /tmp/gyPxoY_version.c 2020-09-11 11:21:56.710842800 +0200 --- /tmp/CJjzlY_version.c 2020-09-11 11:21:56.714842792 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1654, /**/ -- Shaw's Principle: Build a system that even a fool can use, and only a fool will want to use it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///