updated for version 7.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.
			
			
This commit is contained in:
		@ -4408,6 +4408,8 @@ do_sub(eap)
 | 
				
			|||||||
	    && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
 | 
						    && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
 | 
				
			||||||
					     || *cmd == 'p' || *cmd == '#'))))
 | 
										     || *cmd == 'p' || *cmd == '#'))))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
						linenr_T    joined_lines_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	curwin->w_cursor.lnum = eap->line1;
 | 
						curwin->w_cursor.lnum = eap->line1;
 | 
				
			||||||
	if (*cmd == 'l')
 | 
						if (*cmd == 'l')
 | 
				
			||||||
	    eap->flags = EXFLAG_LIST;
 | 
						    eap->flags = EXFLAG_LIST;
 | 
				
			||||||
@ -4416,10 +4418,27 @@ do_sub(eap)
 | 
				
			|||||||
	else if (*cmd == 'p')
 | 
						else if (*cmd == 'p')
 | 
				
			||||||
	    eap->flags = EXFLAG_PRINT;
 | 
						    eap->flags = EXFLAG_PRINT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	(void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE, TRUE);
 | 
						/* The number of lines joined is the number of lines in the range plus
 | 
				
			||||||
	sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
 | 
						 * one.  One less when the last line is included. */
 | 
				
			||||||
	(void)do_sub_msg(FALSE);
 | 
						joined_lines_count = eap->line2 - eap->line1 + 1;
 | 
				
			||||||
	ex_may_print(eap);
 | 
						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;
 | 
						return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
int search_regcomp __ARGS((char_u *pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch));
 | 
					int search_regcomp __ARGS((char_u *pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch));
 | 
				
			||||||
char_u *get_search_pat __ARGS((void));
 | 
					char_u *get_search_pat __ARGS((void));
 | 
				
			||||||
char_u *reverse_text __ARGS((char_u *s));
 | 
					char_u *reverse_text __ARGS((char_u *s));
 | 
				
			||||||
 | 
					void save_re_pat __ARGS((int idx, char_u *pat, int magic));
 | 
				
			||||||
void save_search_patterns __ARGS((void));
 | 
					void save_search_patterns __ARGS((void));
 | 
				
			||||||
void restore_search_patterns __ARGS((void));
 | 
					void restore_search_patterns __ARGS((void));
 | 
				
			||||||
void free_search_patterns __ARGS((void));
 | 
					void free_search_patterns __ARGS((void));
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "vim.h"
 | 
					#include "vim.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void save_re_pat __ARGS((int idx, char_u *pat, int magic));
 | 
					 | 
				
			||||||
#ifdef FEAT_EVAL
 | 
					#ifdef FEAT_EVAL
 | 
				
			||||||
static void set_vv_searchforward __ARGS((void));
 | 
					static void set_vv_searchforward __ARGS((void));
 | 
				
			||||||
static int first_submatch __ARGS((regmmatch_T *rp));
 | 
					static int first_submatch __ARGS((regmmatch_T *rp));
 | 
				
			||||||
@ -272,7 +271,7 @@ reverse_text(s)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static void
 | 
					    void
 | 
				
			||||||
save_re_pat(idx, pat, magic)
 | 
					save_re_pat(idx, pat, magic)
 | 
				
			||||||
    int		idx;
 | 
					    int		idx;
 | 
				
			||||||
    char_u	*pat;
 | 
					    char_u	*pat;
 | 
				
			||||||
 | 
				
			|||||||
@ -741,6 +741,8 @@ static char *(features[]) =
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int included_patches[] =
 | 
					static int included_patches[] =
 | 
				
			||||||
{   /* Add new patch number below this line */
 | 
					{   /* Add new patch number below this line */
 | 
				
			||||||
 | 
					/**/
 | 
				
			||||||
 | 
					    543,
 | 
				
			||||||
/**/
 | 
					/**/
 | 
				
			||||||
    542,
 | 
					    542,
 | 
				
			||||||
/**/
 | 
					/**/
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user