comparison src/terminal.c @ 12011:1f4e7361ce89 v8.0.0886

patch 8.0.0886: crash when using ":term ls" commit https://github.com/vim/vim/commit/f8d57a50496d854f3e82725bfde1543c9d01ff98 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 7 20:38:42 2017 +0200 patch 8.0.0886: crash when using ":term ls" Problem: Crash when using ":term ls". Solution: Fix line number computation. Add a test for this.
author Christian Brabandt <cb@256bit.org>
date Mon, 07 Aug 2017 20:45:04 +0200
parents 0d9bfdb3f6f7
children e30f3d1fdea7
comparison
equal deleted inserted replaced
12010:93589e148d03 12011:1f4e7361ce89
693 * Add the last line of the scrollback buffer to the buffer in the window. 693 * Add the last line of the scrollback buffer to the buffer in the window.
694 */ 694 */
695 static void 695 static void
696 add_scrollback_line_to_buffer(term_T *term, char_u *text, int len) 696 add_scrollback_line_to_buffer(term_T *term, char_u *text, int len)
697 { 697 {
698 linenr_T lnum = term->tl_scrollback.ga_len - 1; 698 buf_T *buf = term->tl_buffer;
699 int empty = (buf->b_ml.ml_flags & ML_EMPTY);
700 linenr_T lnum = buf->b_ml.ml_line_count;
699 701
700 ml_append_buf(term->tl_buffer, lnum, text, len + 1, FALSE); 702 ml_append_buf(term->tl_buffer, lnum, text, len + 1, FALSE);
701 if (lnum == 0) 703 if (empty)
702 { 704 {
703 /* Delete the empty line that was in the empty buffer. */ 705 /* Delete the empty line that was in the empty buffer. */
704 curbuf = term->tl_buffer; 706 curbuf = buf;
705 ml_delete(2, FALSE); 707 ml_delete(1, FALSE);
706 curbuf = curwin->w_buffer; 708 curbuf = curwin->w_buffer;
707 } 709 }
708 } 710 }
709 711
710 /* 712 /*