summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0356
blob: 907ebef7e40d758409ad0222ad075b51099e988e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0356
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0356
Problem:    Using :s with 'incsearch' prevents CTRL-R CTRL-W. (Boris Staletic)
Solution:   When past the pattern put cursor back in the start position.
            (closes #3413)
Files:	    src/ex_getln.c, src/testdir/test_search.vim


*** ../vim-8.1.0355/src/ex_getln.c	2018-09-06 21:44:13.660006996 +0200
--- src/ex_getln.c	2018-09-09 15:53:37.117142011 +0200
***************
*** 462,468 ****
  	incsearch_state_T   *is_state)
  {
      int		skiplen, patlen;
!     int		i;
      pos_T	end_pos;
      struct cmdline_info	save_ccline;
  #ifdef FEAT_RELTIME
--- 462,468 ----
  	incsearch_state_T   *is_state)
  {
      int		skiplen, patlen;
!     int		found;  // do_search() result
      pos_T	end_pos;
      struct cmdline_info	save_ccline;
  #ifdef FEAT_RELTIME
***************
*** 508,514 ****
      // If there is no pattern, don't do anything.
      if (patlen == 0 && !use_last_pat)
      {
! 	i = 0;
  	set_no_hlsearch(TRUE); // turn off previous highlight
  	redraw_all_later(SOME_VALID);
      }
--- 508,514 ----
      // If there is no pattern, don't do anything.
      if (patlen == 0 && !use_last_pat)
      {
! 	found = 0;
  	set_no_hlsearch(TRUE); // turn off previous highlight
  	redraw_all_later(SOME_VALID);
      }
***************
*** 528,534 ****
  	if (search_first_line != 0)
  	    search_flags += SEARCH_START;
  	ccline.cmdbuff[skiplen + patlen] = NUL;
! 	i = do_search(NULL, firstc == ':' ? '/' : firstc,
  				 ccline.cmdbuff + skiplen, count, search_flags,
  #ifdef FEAT_RELTIME
  		&tm, NULL
--- 528,534 ----
  	if (search_first_line != 0)
  	    search_flags += SEARCH_START;
  	ccline.cmdbuff[skiplen + patlen] = NUL;
! 	found = do_search(NULL, firstc == ':' ? '/' : firstc,
  				 ccline.cmdbuff + skiplen, count, search_flags,
  #ifdef FEAT_RELTIME
  		&tm, NULL
***************
*** 543,549 ****
  		|| curwin->w_cursor.lnum > search_last_line)
  	{
  	    // match outside of address range
! 	    i = 0;
  	    curwin->w_cursor = is_state->search_start;
  	}
  
--- 543,549 ----
  		|| curwin->w_cursor.lnum > search_last_line)
  	{
  	    // match outside of address range
! 	    found = 0;
  	    curwin->w_cursor = is_state->search_start;
  	}
  
***************
*** 552,564 ****
  	{
  	    (void)vpeekc();	// remove <C-C> from input stream
  	    got_int = FALSE;	// don't abandon the command line
! 	    i = 0;
  	}
  	else if (char_avail())
  	    // cancelled searching because a char was typed
  	    is_state->incsearch_postponed = TRUE;
      }
!     if (i != 0)
  	highlight_match = TRUE;		// highlight position
      else
  	highlight_match = FALSE;	// remove highlight
--- 552,564 ----
  	{
  	    (void)vpeekc();	// remove <C-C> from input stream
  	    got_int = FALSE;	// don't abandon the command line
! 	    found = 0;
  	}
  	else if (char_avail())
  	    // cancelled searching because a char was typed
  	    is_state->incsearch_postponed = TRUE;
      }
!     if (found != 0)
  	highlight_match = TRUE;		// highlight position
      else
  	highlight_match = FALSE;	// remove highlight
***************
*** 569,575 ****
      changed_cline_bef_curs();
      update_topline();
  
!     if (i != 0)
      {
  	pos_T	    save_pos = curwin->w_cursor;
  
--- 569,575 ----
      changed_cline_bef_curs();
      update_topline();
  
!     if (found != 0)
      {
  	pos_T	    save_pos = curwin->w_cursor;
  
***************
*** 604,611 ****
      restore_cmdline(&save_ccline);
      restore_last_search_pattern();
  
!     // Leave it at the end to make CTRL-R CTRL-W work.
!     if (i != 0)
  	curwin->w_cursor = end_pos;
  
      msg_starthere();
--- 604,614 ----
      restore_cmdline(&save_ccline);
      restore_last_search_pattern();
  
!     // Leave it at the end to make CTRL-R CTRL-W work.  But not when beyond the
!     // end of the pattern, e.g. for ":s/pat/".
!     if (ccline.cmdbuff[skiplen + patlen] != NUL)
! 	curwin->w_cursor = is_state->search_start;
!     else if (found != 0)
  	curwin->w_cursor = end_pos;
  
      msg_starthere();
*** ../vim-8.1.0355/src/testdir/test_search.vim	2018-09-06 21:44:13.660006996 +0200
--- src/testdir/test_search.vim	2018-09-09 15:50:31.934618534 +0200
***************
*** 1060,1065 ****
--- 1060,1101 ----
    set noincsearch
  endfunc
  
+ func Test_word_under_cursor_after_match()
+   if !exists('+incsearch')
+     return
+   endif
+   new
+   call setline(1, 'foo bar')
+   set incsearch
+   call test_override("char_avail", 1)
+   try
+     call feedkeys("/foo\<C-R>\<C-W>\<CR>", 'ntx')
+   catch /E486:/
+   endtry
+   call assert_equal('foobar', @/)
+ 
+   bwipe!
+   call test_override("ALL", 0)
+   set noincsearch
+ endfunc
+ 
+ func Test_subst_word_under_cursor()
+   if !exists('+incsearch')
+     return
+   endif
+   new
+   call setline(1, ['int SomeLongName;', 'for (xxx = 1; xxx < len; ++xxx)'])
+   set incsearch
+   call test_override("char_avail", 1)
+   call feedkeys("/LongName\<CR>", 'ntx')
+   call feedkeys(":%s/xxx/\<C-R>\<C-W>/g\<CR>", 'ntx')
+   call assert_equal('for (SomeLongName = 1; SomeLongName < len; ++SomeLongName)', getline(2))
+ 
+   bwipe!
+   call test_override("ALL", 0)
+   set noincsearch
+ endfunc
+ 
  func Test_search_undefined_behaviour()
    if !has("terminal")
      return
*** ../vim-8.1.0355/src/version.c	2018-09-09 15:27:54.812344748 +0200
--- src/version.c	2018-09-09 15:52:51.437517050 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     356,
  /**/

-- 
"So this is it," said Arthur, "we are going to die."
"Yes," said Ford, "except...no!  Wait a minute!"  He suddenly lunged across
the chamber at something behind Arthur's line of vision.  "What's this
switch?" he cried.
"What?   Where?" cried Arthur, twisting around.
"No, I was only fooling," said Ford, "we are going to die after all."
		-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///