diff options
| author | Bram Moolenaar <Bram@vim.org> | 2016-03-08 14:44:42 +0100 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2016-03-08 14:44:42 +0100 |
| commit | 41e0f2f48f541eb2c8eb5620d3f1d270eb979154 (patch) | |
| tree | edcad48fd7b7003cb5acaa54527e3119c154abf8 /src/normal.c | |
| parent | 94d0191dbcce829ad9b92d902b6e2717041db3b8 (diff) | |
| download | vim-git-41e0f2f48f541eb2c8eb5620d3f1d270eb979154.tar.gz | |
patch 7.4.1513v7.4.1513
Problem: "J" fails if there are not enough lines. (Christian Neukirchen)
Solution: Reduce the count, only fail on the last line.
Diffstat (limited to 'src/normal.c')
| -rw-r--r-- | src/normal.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/normal.c b/src/normal.c index b57191ae0..7f0d8bd74 100644 --- a/src/normal.c +++ b/src/normal.c @@ -9213,13 +9213,20 @@ nv_join(cmdarg_T *cap) cap->count0 = 2; /* default for join is two lines! */ if (curwin->w_cursor.lnum + cap->count0 - 1 > curbuf->b_ml.ml_line_count) - clearopbeep(cap->oap); /* beyond last line */ - else { - prep_redo(cap->oap->regname, cap->count0, - NUL, cap->cmdchar, NUL, NUL, cap->nchar); - (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); + /* can't join when on the last line */ + if (cap->count0 <= 2) + { + clearopbeep(cap->oap); + return; + } + cap->count0 = curbuf->b_ml.ml_line_count + - curwin->w_cursor.lnum + 1; } + + prep_redo(cap->oap->regname, cap->count0, + NUL, cap->cmdchar, NUL, NUL, cap->nchar); + (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); } } |
