diff options
Diffstat (limited to 'src/nvim/normal.c')
| -rw-r--r-- | src/nvim/normal.c | 44 | 
1 files changed, 28 insertions, 16 deletions
| diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ee3c3f9f11..7188e13436 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1596,6 +1596,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)        oap->start = curwin->w_cursor;      } +    // Just in case lines were deleted that make the position invalid. +    check_pos(curwin->w_buffer, &oap->end);      oap->line_count = oap->end.lnum - oap->start.lnum + 1;      /* Set "virtual_op" before resetting VIsual_active. */ @@ -1899,12 +1901,13 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)        break;      case OP_FORMAT: -      if (*curbuf->b_p_fex != NUL) -        op_formatexpr(oap);             /* use expression */ -      else if (*p_fp != NUL) -        op_colon(oap);                  /* use external command */ -      else -        op_format(oap, false);          /* use internal function */ +      if (*curbuf->b_p_fex != NUL) { +        op_formatexpr(oap);             // use expression +      } else if (*p_fp != NUL || *curbuf->b_p_fp != NUL) { +        op_colon(oap);                  // use external command +      } else { +        op_format(oap, false);          // use internal function +      }        break;      case OP_FORMAT2: @@ -1912,7 +1915,10 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)        break;      case OP_FUNCTION: -      op_function(oap);                 /* call 'operatorfunc' */ +      // Restore linebreak, so that when the user edits it looks as +      // before. +      curwin->w_p_lbr = lbr_saved; +      op_function(oap);                 // call 'operatorfunc'        break;      case OP_INSERT: @@ -2059,10 +2065,13 @@ static void op_colon(oparg_T *oap)      stuffReadbuff(get_equalprg());      stuffReadbuff((char_u *)"\n");    } else if (oap->op_type == OP_FORMAT) { -    if (*p_fp == NUL) -      stuffReadbuff((char_u *)"fmt"); -    else +    if (*curbuf->b_p_fp != NUL) { +      stuffReadbuff(curbuf->b_p_fp); +    } else if (*p_fp != NUL) {        stuffReadbuff(p_fp); +    } else { +      stuffReadbuff((char_u *)"fmt"); +    }      stuffReadbuff((char_u *)"\n']");    } @@ -4757,13 +4766,16 @@ static void nv_ident(cmdarg_T *cap)      }    } -  /* -   * Now grab the chars in the identifier -   */ -  if (cmdchar == 'K' && !kp_ex) { -    /* Escape the argument properly for a shell command */ +  // Now grab the chars in the identifier +  if (cmdchar == 'K') {      ptr = vim_strnsave(ptr, n); -    p = vim_strsave_shellescape(ptr, true, true); +    if (kp_ex) { +      // Escape the argument properly for an Ex command +      p = vim_strsave_fnameescape(ptr, false); +    } else { +      // Escape the argument properly for a shell command +      p = vim_strsave_shellescape(ptr, true, true); +    }      xfree(ptr);      char *newbuf = xrealloc(buf, STRLEN(buf) + STRLEN(p) + 1);      buf = newbuf; | 
