mirror of
https://github.com/neovim/neovim.git
synced 2025-11-22 18:16:32 +00:00
Fix newline substitution.
Problem : Command `s/\n//` is being translated into a call to do_join
with a count of 1. But do_join asserts its precondition count
>= 2, which is causing the program to abort.
Note : This in fact revealed bigger problems: generated join command
line count, as well as reported substitutions/lines were
wrong in several cases, since patch 7.4.232.
See:
[patch] http://markmail.org/message/vo7ruair5raccawp
[issue] https://code.google.com/p/vim/issues/detail?id=287
Solution : - Don't generate join command for single-line-range case.
- Make generated join command include:
* lines in range + 1, when range doesn't end at last line.
* lines in range, when range ends at last line.
- Make reported substitutions/lines always be
number-of-lines-joined - 1.
This commit is contained in:
@@ -3602,8 +3602,13 @@ void do_sub(exarg_T *eap)
|
||||
eap->flags = EXFLAG_PRINT;
|
||||
}
|
||||
|
||||
do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE, true);
|
||||
sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
|
||||
linenr_T joined_lines_count = eap->line2 < curbuf->b_ml.ml_line_count
|
||||
? eap->line2 - eap->line1 + 2
|
||||
: eap->line2 - eap->line1 + 1;
|
||||
if (joined_lines_count >= 2) {
|
||||
do_join(joined_lines_count, FALSE, TRUE, FALSE, true);
|
||||
}
|
||||
sub_nlines = sub_nsubs = joined_lines_count - 1;
|
||||
do_sub_msg(false);
|
||||
ex_may_print(eap);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user