Mercurial > vim
comparison src/search.c @ 14000:96933f0ecbd1 v8.1.0018
patch 8.1.0018: using "gn" may select wrong text when wrapping
commit https://github.com/vim/vim/commit/bdb657924d73c98b0ab28411749571e893b699a9
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 22 17:50:42 2018 +0200
patch 8.1.0018: using "gn" may select wrong text when wrapping
Problem: Using "gn" may select wrong text when wrapping.
Solution: Avoid wrapping when searching forward. (Christian Brabandt)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 22 May 2018 18:00:07 +0200 |
parents | 0e9b2971d7c3 |
children | ec85acd49b8e |
comparison
equal
deleted
inserted
replaced
13999:f4d1227b4b20 | 14000:96933f0ecbd1 |
---|---|
4663 long count, | 4663 long count, |
4664 int forward) /* move forward or backwards */ | 4664 int forward) /* move forward or backwards */ |
4665 { | 4665 { |
4666 pos_T start_pos; /* position before the pattern */ | 4666 pos_T start_pos; /* position before the pattern */ |
4667 pos_T orig_pos; /* position of the cursor at beginning */ | 4667 pos_T orig_pos; /* position of the cursor at beginning */ |
4668 pos_T first_match; /* position of first match */ | |
4668 pos_T pos; /* position after the pattern */ | 4669 pos_T pos; /* position after the pattern */ |
4669 int i; | 4670 int i; |
4670 int dir; | 4671 int dir; |
4671 int result; /* result of various function calls */ | 4672 int result; /* result of various function calls */ |
4672 char_u old_p_ws = p_ws; | 4673 char_u old_p_ws = p_ws; |
4756 pos.lnum = curwin->w_buffer->b_ml.ml_line_count; | 4757 pos.lnum = curwin->w_buffer->b_ml.ml_line_count; |
4757 pos.col = (colnr_T)STRLEN( | 4758 pos.col = (colnr_T)STRLEN( |
4758 ml_get(curwin->w_buffer->b_ml.ml_line_count)); | 4759 ml_get(curwin->w_buffer->b_ml.ml_line_count)); |
4759 } | 4760 } |
4760 } | 4761 } |
4762 if (i == 0) | |
4763 first_match = pos; | |
4761 p_ws = old_p_ws; | 4764 p_ws = old_p_ws; |
4762 } | 4765 } |
4763 | 4766 |
4764 start_pos = pos; | 4767 start_pos = pos; |
4765 flags = forward ? SEARCH_END : SEARCH_START; | 4768 flags = forward ? SEARCH_END : SEARCH_START; |
4772 return FAIL; | 4775 return FAIL; |
4773 | 4776 |
4774 /* move to match, except for zero-width matches, in which case, we are | 4777 /* move to match, except for zero-width matches, in which case, we are |
4775 * already on the next match */ | 4778 * already on the next match */ |
4776 if (!one_char) | 4779 if (!one_char) |
4777 result = searchit(curwin, curbuf, &pos, direction, | 4780 { |
4781 p_ws = FALSE; | |
4782 for (i = 0; i < 2; i++) | |
4783 { | |
4784 result = searchit(curwin, curbuf, &pos, direction, | |
4778 spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, | 4785 spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, |
4779 NULL, NULL); | 4786 NULL, NULL); |
4787 /* Search successfull, break out from the loop */ | |
4788 if (result) | |
4789 break; | |
4790 /* search failed, try again from the last search position match */ | |
4791 pos = first_match; | |
4792 } | |
4793 } | |
4794 | |
4795 p_ws = old_p_ws; | |
4796 /* not found */ | |
4797 if (!result) | |
4798 return FAIL; | |
4780 | 4799 |
4781 if (!VIsual_active) | 4800 if (!VIsual_active) |
4782 VIsual = start_pos; | 4801 VIsual = start_pos; |
4783 | 4802 |
4784 curwin->w_cursor = pos; | 4803 curwin->w_cursor = pos; |