patch 8.1.1457: cannot reuse a buffer when loading a screen dump
Problem: Cannot reuse a buffer when loading a screen dump.
Solution: Add the "bufnr" option.
diff --git a/src/terminal.c b/src/terminal.c
index 2b964ae..1764b05 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -4616,7 +4616,7 @@
term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
{
jobopt_T opt;
- buf_T *buf;
+ buf_T *buf = NULL;
char_u buf1[NUMBUFLEN];
char_u buf2[NUMBUFLEN];
char_u *fname1;
@@ -4671,7 +4671,27 @@
}
}
- buf = term_start(&argvars[0], NULL, &opt, TERM_START_NOJOB);
+ if (opt.jo_bufnr_buf != NULL)
+ {
+ win_T *wp = buf_jump_open_win(opt.jo_bufnr_buf);
+
+ // With "bufnr" argument: enter the window with this buffer and make it
+ // empty.
+ if (wp == NULL)
+ semsg(_(e_invarg2), "bufnr");
+ else
+ {
+ buf = curbuf;
+ while (!(curbuf->b_ml.ml_flags & ML_EMPTY))
+ ml_delete((linenr_T)1, FALSE);
+ ga_clear(&curbuf->b_term->tl_scrollback);
+ redraw_later(NOT_VALID);
+ }
+ }
+ else
+ // Create a new terminal window.
+ buf = term_start(&argvars[0], NULL, &opt, TERM_START_NOJOB);
+
if (buf != NULL && buf->b_term != NULL)
{
int i;