diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-12-13 03:17:11 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-12-13 03:17:11 +0100 |
commit | cc2b9d5dc08cefa0342a25ece71b21d4b4b32e00 (patch) | |
tree | 6034465936f933c63ccd81d791e8425dd1142843 /src/ex_cmds.c | |
parent | f1d6ccf2f9c8a8ae2c0ec4577946397c103ead2b (diff) |
updated for version 7.4.543v7.4.543
Problem: Since patch 7.4.232 "1,3s/\n//" joins two lines instead of three.
(Eliseo MartÃnez) Issue 287
Solution: Correct the line count. (Christian Brabandt)
Also set the last used search pattern.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 86dab4797d..8195eb71b8 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4408,6 +4408,8 @@ do_sub(eap) && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l' || *cmd == 'p' || *cmd == '#')))) { + linenr_T joined_lines_count; + curwin->w_cursor.lnum = eap->line1; if (*cmd == 'l') eap->flags = EXFLAG_LIST; @@ -4416,10 +4418,27 @@ do_sub(eap) else if (*cmd == 'p') eap->flags = EXFLAG_PRINT; - (void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE, TRUE); - sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1; - (void)do_sub_msg(FALSE); - ex_may_print(eap); + /* The number of lines joined is the number of lines in the range plus + * one. One less when the last line is included. */ + joined_lines_count = eap->line2 - eap->line1 + 1; + if (eap->line2 < curbuf->b_ml.ml_line_count) + ++joined_lines_count; + if (joined_lines_count > 1) + { + (void)do_join(joined_lines_count, FALSE, TRUE, FALSE, TRUE); + sub_nsubs = joined_lines_count - 1; + sub_nlines = 1; + (void)do_sub_msg(FALSE); + ex_may_print(eap); + } + + if (!cmdmod.keeppatterns) + save_re_pat(RE_SUBST, pat, p_magic); +#ifdef FEAT_CMDHIST + /* put pattern in history */ + add_to_history(HIST_SEARCH, pat, TRUE, NUL); +#endif + return; } |