Mercurial > vim
comparison src/search.c @ 1544:fc42d9cc7ad0 v7.1.258
updated for version 7.1-258
author | vimboss |
---|---|
date | Wed, 20 Feb 2008 12:43:01 +0000 |
parents | 03ec0f2b9a40 |
children | 811f29447aea |
comparison
equal
deleted
inserted
replaced
1543:6c73a0d9f511 | 1544:fc42d9cc7ad0 |
---|---|
622 matchpos = regmatch.startpos[0]; | 622 matchpos = regmatch.startpos[0]; |
623 endpos = regmatch.endpos[0]; | 623 endpos = regmatch.endpos[0]; |
624 #ifdef FEAT_EVAL | 624 #ifdef FEAT_EVAL |
625 submatch = first_submatch(®match); | 625 submatch = first_submatch(®match); |
626 #endif | 626 #endif |
627 /* Line me be past end of buffer for "\n\zs". */ | 627 /* "lnum" may be past end of buffer for "\n\zs". */ |
628 if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) | 628 if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) |
629 ptr = (char_u *)""; | 629 ptr = (char_u *)""; |
630 else | 630 else |
631 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); | 631 ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); |
632 | 632 |
831 */ | 831 */ |
832 if (!match_ok) | 832 if (!match_ok) |
833 continue; | 833 continue; |
834 } | 834 } |
835 | 835 |
836 if (options & SEARCH_END && !(options & SEARCH_NOOF)) | 836 /* With the SEARCH_END option move to the last character |
837 * of the match. Don't do it for an empty match, end | |
838 * should be same as start then. */ | |
839 if (options & SEARCH_END && !(options & SEARCH_NOOF) | |
840 && !(matchpos.lnum == endpos.lnum | |
841 && matchpos.col == endpos.col)) | |
837 { | 842 { |
843 /* For a match in the first column, set the position | |
844 * on the NUL in the previous line. */ | |
838 pos->lnum = lnum + endpos.lnum; | 845 pos->lnum = lnum + endpos.lnum; |
839 pos->col = endpos.col - 1; | 846 pos->col = endpos.col; |
847 if (endpos.col == 0) | |
848 { | |
849 if (pos->lnum > 1) /* just in case */ | |
850 { | |
851 --pos->lnum; | |
852 pos->col = (colnr_T)STRLEN(ml_get_buf(buf, | |
853 pos->lnum, FALSE)); | |
854 } | |
855 } | |
856 else | |
857 { | |
858 --pos->col; | |
840 #ifdef FEAT_MBYTE | 859 #ifdef FEAT_MBYTE |
841 if (has_mbyte) | 860 if (has_mbyte |
842 { | 861 && pos->lnum <= buf->b_ml.ml_line_count) |
843 /* 'e' offset may put us just below the last line */ | 862 { |
844 if (pos->lnum > buf->b_ml.ml_line_count) | |
845 ptr = (char_u *)""; | |
846 else | |
847 ptr = ml_get_buf(buf, pos->lnum, FALSE); | 863 ptr = ml_get_buf(buf, pos->lnum, FALSE); |
848 pos->col -= (*mb_head_off)(ptr, ptr + pos->col); | 864 pos->col -= (*mb_head_off)(ptr, ptr + pos->col); |
865 } | |
866 #endif | |
849 } | 867 } |
850 #endif | |
851 } | 868 } |
852 else | 869 else |
853 { | 870 { |
854 pos->lnum = lnum + matchpos.lnum; | 871 pos->lnum = lnum + matchpos.lnum; |
855 pos->col = matchpos.col; | 872 pos->col = matchpos.col; |