diff options
Diffstat (limited to 'src/nvim/ex_cmds2.c')
| -rw-r--r-- | src/nvim/ex_cmds2.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 4684a1b31d..40ff29d4a8 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1298,7 +1298,12 @@ void dialog_changed(buf_T *buf, bool checkall) { char_u buff[DIALOG_MSG_SIZE]; int ret; - exarg_T ea; + // Init ea pseudo-structure, this is needed for the check_overwrite() + // function. + exarg_T ea = { + .append = false, + .forceit = false, + }; dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname); if (checkall) { @@ -1307,10 +1312,6 @@ void dialog_changed(buf_T *buf, bool checkall) ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); } - // Init ea pseudo-structure, this is needed for the check_overwrite() - // function. - ea.append = ea.forceit = false; - if (ret == VIM_YES) { if (buf->b_fname != NULL && check_overwrite(&ea, @@ -1952,14 +1953,17 @@ void ex_next(exarg_T *eap) void ex_argedit(exarg_T *eap) { int i = eap->addr_count ? (int)eap->line2 : curwin->w_arg_idx + 1; + // Whether curbuf will be reused, curbuf->b_ffname will be set. + bool curbuf_is_reusable = curbuf_reusable(); if (do_arglist(eap->arg, AL_ADD, i) == FAIL) { return; } maketitle(); - if (curwin->w_arg_idx == 0 && (curbuf->b_ml.ml_flags & ML_EMPTY) - && curbuf->b_ffname == NULL) { + if (curwin->w_arg_idx == 0 + && (curbuf->b_ml.ml_flags & ML_EMPTY) + && (curbuf->b_ffname == NULL || curbuf_is_reusable)) { i = 0; } // Edit the argument. @@ -2257,7 +2261,8 @@ static int alist_add_list(int count, char_u **files, int after) } for (int i = 0; i < count; i++) { ARGLIST[after + i].ae_fname = files[i]; - ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED); + ARGLIST[after + i].ae_fnum = buflist_add(files[i], + BLN_LISTED | BLN_CURBUF); } ALIST(curwin)->al_ga.ga_len += count; if (old_argcount > 0 && curwin->w_arg_idx >= after) { @@ -3399,13 +3404,18 @@ char_u *getsourceline(int c, void *cookie, int indent) // Get the next line and concatenate it when it starts with a // backslash. We always need to read the next line, keep it in // sp->nextline. + // Also check for a comment in between continuation lines: "\ . sp->nextline = get_one_sourceline(sp); - if (sp->nextline != NULL && *(p = skipwhite(sp->nextline)) == '\\') { + if (sp->nextline != NULL + && (*(p = skipwhite(sp->nextline)) == '\\' + || (p[0] == '"' && p[1] == '\\' && p[2] == ' '))) { garray_T ga; ga_init(&ga, (int)sizeof(char_u), 400); ga_concat(&ga, line); - ga_concat(&ga, p + 1); + if (*p == '\\') { + ga_concat(&ga, p + 1); + } for (;; ) { xfree(sp->nextline); sp->nextline = get_one_sourceline(sp); @@ -3413,15 +3423,16 @@ char_u *getsourceline(int c, void *cookie, int indent) break; } p = skipwhite(sp->nextline); - if (*p != '\\') { + if (*p == '\\') { + // Adjust the growsize to the current length to speed up + // concatenating many lines. + if (ga.ga_len > 400) { + ga_set_growsize(&ga, (ga.ga_len > 8000) ? 8000 : ga.ga_len); + } + ga_concat(&ga, p + 1); + } else if (p[0] != '"' || p[1] != '\\' || p[2] != ' ') { break; } - // Adjust the growsize to the current length to speed up - // concatenating many lines. - if (ga.ga_len > 400) { - ga_set_growsize(&ga, (ga.ga_len > 8000) ? 8000 : ga.ga_len); - } - ga_concat(&ga, p + 1); } ga_append(&ga, NUL); xfree(line); |