0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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.
This commit is contained in:
Bram Moolenaar
2017-08-07 20:38:42 +02:00
parent 33a43bee9c
commit f8d57a5049
3 changed files with 33 additions and 4 deletions

View File

@@ -695,14 +695,16 @@ term_job_running(term_T *term)
static void
add_scrollback_line_to_buffer(term_T *term, char_u *text, int len)
{
linenr_T lnum = term->tl_scrollback.ga_len - 1;
buf_T *buf = term->tl_buffer;
int empty = (buf->b_ml.ml_flags & ML_EMPTY);
linenr_T lnum = buf->b_ml.ml_line_count;
ml_append_buf(term->tl_buffer, lnum, text, len + 1, FALSE);
if (lnum == 0)
if (empty)
{
/* Delete the empty line that was in the empty buffer. */
curbuf = term->tl_buffer;
ml_delete(2, FALSE);
curbuf = buf;
ml_delete(1, FALSE);
curbuf = curwin->w_buffer;
}
}