diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-24 11:43:51 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-24 11:43:51 +0200 | 
| commit | d51f132cb150a5adeac9e40ec7409040f32d880e (patch) | |
| tree | b9f177db85f96cb79a89706b0448b7add23d1e66 /src/nvim/normal.c | |
| parent | 66d127957ed3cc27af0344c742bc5acedd347894 (diff) | |
| parent | f1464d0d8023d409906c1a0d2c59e88623bef2e5 (diff) | |
| download | rneovim-d51f132cb150a5adeac9e40ec7409040f32d880e.tar.gz rneovim-d51f132cb150a5adeac9e40ec7409040f32d880e.tar.bz2 rneovim-d51f132cb150a5adeac9e40ec7409040f32d880e.zip  | |
Merge #10054 from janlazo/vim-8.1.1373
vim-patch:8.0.{1208,1220},8.1.{1171,1373}
Diffstat (limited to 'src/nvim/normal.c')
| -rw-r--r-- | src/nvim/normal.c | 65 | 
1 files changed, 19 insertions, 46 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ca586cca29..04eede18bd 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5633,49 +5633,9 @@ static void nv_brackets(cmdarg_T *cap)        if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)          foldOpenCursor();      } -  } -  /* -   * "[p", "[P", "]P" and "]p": put with indent adjustment -   */ -  else if (cap->nchar == 'p' || cap->nchar == 'P') { -    if (!checkclearop(cap->oap)) { -      int dir = (cap->cmdchar == ']' && cap->nchar == 'p') ? FORWARD : BACKWARD; -      int regname = cap->oap->regname; -      int was_visual = VIsual_active; -      linenr_T line_count = curbuf->b_ml.ml_line_count; -      pos_T start, end; - -      if (VIsual_active) { -        start = ltoreq(VIsual, curwin->w_cursor) ? VIsual : curwin->w_cursor; -        end = equalpos(start, VIsual) ? curwin->w_cursor : VIsual; -        curwin->w_cursor = (dir == BACKWARD ? start : end); -      } -      prep_redo_cmd(cap); -      do_put(regname, NULL, dir, cap->count1, PUT_FIXINDENT); -      if (was_visual) { -        VIsual = start; -        curwin->w_cursor = end; -        if (dir == BACKWARD) { -          /* adjust lines */ -          VIsual.lnum += curbuf->b_ml.ml_line_count - line_count; -          curwin->w_cursor.lnum += curbuf->b_ml.ml_line_count - line_count; -        } - -        VIsual_active = true; -        if (VIsual_mode == 'V') { -          /* delete visually selected lines */ -          cap->cmdchar = 'd'; -          cap->nchar = NUL; -          cap->oap->regname = regname; -          nv_operator(cap); -          do_pending_operator(cap, 0, false); -        } -        if (VIsual_active) { -          end_visual_mode(); -          redraw_later(SOME_VALID); -        } -      } -    } +  } else if (cap->nchar == 'p' || cap->nchar == 'P') { +    // "[p", "[P", "]P" and "]p": put with indent adjustment +    nv_put_opt(cap, true);    }    /*     * "['", "[`", "]'" and "]`": jump to next mark @@ -7799,6 +7759,13 @@ static void nv_join(cmdarg_T *cap)   */  static void nv_put(cmdarg_T *cap)  { +  nv_put_opt(cap, false); +} + +// "P", "gP", "p" and "gp" commands. +// "fix_indent" is true for "[p", "[P", "]p" and "]P". +static void nv_put_opt(cmdarg_T *cap, bool fix_indent) +{    int regname = 0;    yankreg_T *savereg = NULL;    bool empty = false; @@ -7815,9 +7782,15 @@ static void nv_put(cmdarg_T *cap)      } else        clearopbeep(cap->oap);    } else { -    dir = (cap->cmdchar == 'P' -           || (cap->cmdchar == 'g' && cap->nchar == 'P')) -          ? BACKWARD : FORWARD; +    if (fix_indent) { +      dir = (cap->cmdchar == ']' && cap->nchar == 'p') +        ? FORWARD : BACKWARD; +      flags |= PUT_FIXINDENT; +    } else { +      dir = (cap->cmdchar == 'P' +             || (cap->cmdchar == 'g' && cap->nchar == 'P')) +        ? BACKWARD : FORWARD; +    }      prep_redo_cmd(cap);      if (cap->cmdchar == 'g')        flags |= PUT_CURSEND;  | 
