0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.1654: when job writes to hidden buffer current window is wrong

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)
This commit is contained in:
Bram Moolenaar 2020-09-10 21:25:45 +02:00
parent 4f25b1aba0
commit ad9ec5e799
2 changed files with 11 additions and 9 deletions

View File

@ -2619,9 +2619,7 @@ invoke_one_time_callback(
static void static void
append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part) append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
{ {
bufref_T save_curbuf = {NULL, 0, 0}; aco_save_T aco;
win_T *save_curwin = NULL;
tabpage_T *save_curtab = NULL;
linenr_T lnum = buffer->b_ml.ml_line_count; linenr_T lnum = buffer->b_ml.ml_line_count;
int save_write_to = buffer->b_write_to_channel; int save_write_to = buffer->b_write_to_channel;
chanpart_T *ch_part = &channel->ch_part[part]; chanpart_T *ch_part = &channel->ch_part[part];
@ -2647,12 +2645,13 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
} }
// Append to the buffer // Append to the buffer
ch_log(channel, "appending line %d to buffer", (int)lnum + 1 - empty); ch_log(channel, "appending line %d to buffer %s",
(int)lnum + 1 - empty, buffer->b_fname);
buffer->b_p_ma = TRUE; buffer->b_p_ma = TRUE;
// Save curbuf/curwin/curtab and make "buffer" the current buffer. // set curbuf to be our buf, temporarily
switch_to_win_for_buf(buffer, &save_curwin, &save_curtab, &save_curbuf); aucmd_prepbuf(&aco, buffer);
u_sync(TRUE); u_sync(TRUE);
// ignore undo failure, undo is not very useful here // ignore undo failure, undo is not very useful here
@ -2668,8 +2667,8 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
ml_append(lnum, msg, 0, FALSE); ml_append(lnum, msg, 0, FALSE);
appended_lines_mark(lnum, 1L); appended_lines_mark(lnum, 1L);
// Restore curbuf/curwin/curtab // reset notion of buffer
restore_win_for_buf(save_curwin, save_curtab, &save_curbuf); aucmd_restbuf(&aco);
if (ch_part->ch_nomodifiable) if (ch_part->ch_nomodifiable)
buffer->b_p_ma = FALSE; buffer->b_p_ma = FALSE;
@ -2693,9 +2692,10 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
// down. If the topline is outdated update it now. // 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_topline > buffer->b_ml.ml_line_count)
{ {
win_T *save_curwin = curwin;
if (move_cursor) if (move_cursor)
++wp->w_cursor.lnum; ++wp->w_cursor.lnum;
save_curwin = curwin;
curwin = wp; curwin = wp;
curbuf = curwin->w_buffer; curbuf = curwin->w_buffer;
scroll_cursor_bot(0, FALSE); scroll_cursor_bot(0, FALSE);

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1654,
/**/ /**/
1653, 1653,
/**/ /**/