Mercurial > vim
comparison src/ex_cmds.c @ 2126:e038754d419a v7.2.408
updated for version 7.2.408
Problem: With ":g/the/s/foo/bar/" the '[ and '] marks can be set to a line
that was not changed.
Solution: Only set '[ and '] marks when a substitution was done.
author | Bram Moolenaar <bram@zimbu.org> |
---|---|
date | Tue, 23 Mar 2010 17:36:29 +0100 |
parents | 9230c45fdde6 |
children | 4e22214f8464 |
comparison
equal
deleted
inserted
replaced
2125:b8744d1982d1 | 2126:e038754d419a |
---|---|
4236 linenr_T line2; | 4236 linenr_T line2; |
4237 long nmatch; /* number of lines in match */ | 4237 long nmatch; /* number of lines in match */ |
4238 char_u *sub_firstline; /* allocated copy of first sub line */ | 4238 char_u *sub_firstline; /* allocated copy of first sub line */ |
4239 int endcolumn = FALSE; /* cursor in last column when done */ | 4239 int endcolumn = FALSE; /* cursor in last column when done */ |
4240 pos_T old_cursor = curwin->w_cursor; | 4240 pos_T old_cursor = curwin->w_cursor; |
4241 int start_nsubs; | |
4241 | 4242 |
4242 cmd = eap->arg; | 4243 cmd = eap->arg; |
4243 if (!global_busy) | 4244 if (!global_busy) |
4244 { | 4245 { |
4245 sub_nsubs = 0; | 4246 sub_nsubs = 0; |
4246 sub_nlines = 0; | 4247 sub_nlines = 0; |
4247 } | 4248 } |
4249 start_nsubs = sub_nsubs; | |
4248 | 4250 |
4249 if (eap->cmdidx == CMD_tilde) | 4251 if (eap->cmdidx == CMD_tilde) |
4250 which_pat = RE_LAST; /* use last used regexp */ | 4252 which_pat = RE_LAST; /* use last used regexp */ |
4251 else | 4253 else |
4252 which_pat = RE_SUBST; /* use last substitute regexp */ | 4254 which_pat = RE_SUBST; /* use last substitute regexp */ |
5104 | 5106 |
5105 /* ":s/pat//n" doesn't move the cursor */ | 5107 /* ":s/pat//n" doesn't move the cursor */ |
5106 if (do_count) | 5108 if (do_count) |
5107 curwin->w_cursor = old_cursor; | 5109 curwin->w_cursor = old_cursor; |
5108 | 5110 |
5109 if (sub_nsubs) | 5111 if (sub_nsubs > start_nsubs) |
5110 { | 5112 { |
5111 /* Set the '[ and '] marks. */ | 5113 /* Set the '[ and '] marks. */ |
5112 curbuf->b_op_start.lnum = eap->line1; | 5114 curbuf->b_op_start.lnum = eap->line1; |
5113 curbuf->b_op_end.lnum = line2; | 5115 curbuf->b_op_end.lnum = line2; |
5114 curbuf->b_op_start.col = curbuf->b_op_end.col = 0; | 5116 curbuf->b_op_start.col = curbuf->b_op_end.col = 0; |