summaryrefslogtreecommitdiff
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-29 22:10:23 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-29 22:10:23 +0200
commit4641a122f2ffb820ec6d05526532ab38930c5286 (patch)
tree638c53ae9b77dae4daf7a25e36031739e3886263 /src/channel.c
parenteee9f65b2a213e9031f172d9d3b22adad6cb985d (diff)
downloadvim-git-4641a122f2ffb820ec6d05526532ab38930c5286.tar.gz
patch 8.1.1776: text added with a job isn't displayedv8.1.1776
Problem: Text added with a job to another buffer isn't displayed. Solution: Update topline after adding a line. (closes #4745)
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/channel.c b/src/channel.c
index 5d1b83aaf..6351c892c 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -2537,19 +2537,26 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
FOR_ALL_WINDOWS(wp)
{
- if (wp->w_buffer == buffer
- && (save_write_to
- ? wp->w_cursor.lnum == lnum + 1
- : (wp->w_cursor.lnum == lnum
- && wp->w_cursor.col == 0)))
+ if (wp->w_buffer == buffer)
{
- ++wp->w_cursor.lnum;
- save_curwin = curwin;
- curwin = wp;
- curbuf = curwin->w_buffer;
- scroll_cursor_bot(0, FALSE);
- curwin = save_curwin;
- curbuf = curwin->w_buffer;
+ int move_cursor = save_write_to
+ ? wp->w_cursor.lnum == lnum + 1
+ : (wp->w_cursor.lnum == lnum
+ && wp->w_cursor.col == 0);
+
+ // If the cursor is at or above the new line, move it one line
+ // 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);
+ curwin = save_curwin;
+ curbuf = curwin->w_buffer;
+ }
}
}
redraw_buf_and_status_later(buffer, VALID);