summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0277
blob: a084393e41aac807cd1aac544987db7df5cdc066 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0277
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.0277
Problem:    'incsearch' highlighting wrong in a few cases.
Solution:   Fix using last search pattern.  Restore highlighting when changing
            command. (issue #3321)
Files:	    src/ex_getln.c, src/testdir/test_search.vim,
            src/testdir/dumps/Test_incsearch_substitute_02.dump,
            src/testdir/dumps/Test_incsearch_substitute_03.dump


*** ../vim-8.1.0276/src/ex_getln.c	2018-08-12 15:49:33.551438415 +0200
--- src/ex_getln.c	2018-08-12 17:27:32.113306665 +0200
***************
*** 300,306 ****
  		{
  		    delim = *p++;
  		    end = skip_regexp(p, delim, p_magic, NULL);
! 		    if (end > p)
  		    {
  			char_u  *dummy;
  			exarg_T ea;
--- 300,306 ----
  		{
  		    delim = *p++;
  		    end = skip_regexp(p, delim, p_magic, NULL);
! 		    if (end > p || *end == delim)
  		    {
  			char_u  *dummy;
  			exarg_T ea;
***************
*** 341,346 ****
--- 341,377 ----
      return FALSE;
  }
  
+     static void
+ finish_incsearch_highlighting(
+ 	int gotesc,
+ 	incsearch_state_T *is_state,
+ 	int call_update_screen)
+ {
+     if (is_state->did_incsearch)
+     {
+ 	is_state->did_incsearch = FALSE;
+ 	if (gotesc)
+ 	    curwin->w_cursor = is_state->save_cursor;
+ 	else
+ 	{
+ 	    if (!EQUAL_POS(is_state->save_cursor, is_state->search_start))
+ 	    {
+ 		// put the '" mark at the original position
+ 		curwin->w_cursor = is_state->save_cursor;
+ 		setpcmark();
+ 	    }
+ 	    curwin->w_cursor = is_state->search_start;
+ 	}
+ 	restore_viewstate(&is_state->old_viewstate);
+ 	highlight_match = FALSE;
+ 	validate_cursor();	/* needed for TAB */
+ 	if (call_update_screen)
+ 	    update_screen(SOME_VALID);
+ 	else
+ 	    redraw_all_later(SOME_VALID);
+     }
+ }
+ 
  /*
   * Do 'incsearch' highlighting if desired.
   */
***************
*** 357,366 ****
  #ifdef FEAT_RELTIME
      proftime_T	tm;
  #endif
!     int		c;
  
      if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
  	return;
  
      // If there is a character waiting, search and redraw later.
      if (char_avail())
--- 388,401 ----
  #ifdef FEAT_RELTIME
      proftime_T	tm;
  #endif
!     int		next_char;
!     int		use_last_pat;
  
      if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
+     {
+ 	finish_incsearch_highlighting(FALSE, is_state, TRUE);
  	return;
+     }
  
      // If there is a character waiting, search and redraw later.
      if (char_avail())
***************
*** 381,388 ****
      }
      save_last_search_pattern();
  
!     // If there is no command line, don't do anything.
!     if (patlen == 0)
      {
  	i = 0;
  	set_no_hlsearch(TRUE); // turn off previous highlight
--- 416,428 ----
      }
      save_last_search_pattern();
  
!     // Use the previous pattern for ":s//".
!     next_char = ccline.cmdbuff[skiplen + patlen];
!     use_last_pat = patlen == 0 && skiplen > 0
! 				   && ccline.cmdbuff[skiplen - 1] == next_char;
! 
!     // 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
***************
*** 403,409 ****
  	    search_flags += SEARCH_KEEP;
  	if (search_first_line != 0)
  	    search_flags += SEARCH_START;
- 	c = ccline.cmdbuff[skiplen + patlen];
  	ccline.cmdbuff[skiplen + patlen] = NUL;
  	i = do_search(NULL, firstc == ':' ? '/' : firstc,
  				 ccline.cmdbuff + skiplen, count, search_flags,
--- 443,448 ----
***************
*** 413,419 ****
  		NULL, NULL
  #endif
  		);
! 	ccline.cmdbuff[skiplen + patlen] = c;
  	--emsg_off;
  
  	if (curwin->w_cursor.lnum < search_first_line
--- 452,458 ----
  		NULL, NULL
  #endif
  		);
! 	ccline.cmdbuff[skiplen + patlen] = next_char;
  	--emsg_off;
  
  	if (curwin->w_cursor.lnum < search_first_line
***************
*** 459,469 ****
  
      // Disable 'hlsearch' highlighting if the pattern matches everything.
      // Avoids a flash when typing "foo\|".
!     c = ccline.cmdbuff[skiplen + patlen];
!     ccline.cmdbuff[skiplen + patlen] = NUL;
!     if (empty_pattern(ccline.cmdbuff))
! 	set_no_hlsearch(TRUE);
!     ccline.cmdbuff[skiplen + patlen] = c;
  
      validate_cursor();
      // May redraw the status line to show the cursor position.
--- 498,511 ----
  
      // Disable 'hlsearch' highlighting if the pattern matches everything.
      // Avoids a flash when typing "foo\|".
!     if (!use_last_pat)
!     {
! 	next_char = ccline.cmdbuff[skiplen + patlen];
! 	ccline.cmdbuff[skiplen + patlen] = NUL;
! 	if (empty_pattern(ccline.cmdbuff))
! 	    set_no_hlsearch(TRUE);
! 	ccline.cmdbuff[skiplen + patlen] = next_char;
!     }
  
      validate_cursor();
      // May redraw the status line to show the cursor position.
***************
*** 628,657 ****
      }
      return OK;
  }
- 
-     static void
- finish_incsearch_highlighting(int gotesc, incsearch_state_T *is_state)
- {
-     if (is_state->did_incsearch)
-     {
- 	if (gotesc)
- 	    curwin->w_cursor = is_state->save_cursor;
- 	else
- 	{
- 	    if (!EQUAL_POS(is_state->save_cursor, is_state->search_start))
- 	    {
- 		// put the '" mark at the original position
- 		curwin->w_cursor = is_state->save_cursor;
- 		setpcmark();
- 	    }
- 	    curwin->w_cursor = is_state->search_start;
- 	}
- 	restore_viewstate(&is_state->old_viewstate);
- 	highlight_match = FALSE;
- 	validate_cursor();	/* needed for TAB */
- 	redraw_all_later(SOME_VALID);
-     }
- }
  #endif
  
  /*
--- 670,675 ----
***************
*** 2301,2307 ****
      ccline.xpc = NULL;
  
  #ifdef FEAT_SEARCH_EXTRA
!     finish_incsearch_highlighting(gotesc, &is_state);
  #endif
  
      if (ccline.cmdbuff != NULL)
--- 2319,2325 ----
      ccline.xpc = NULL;
  
  #ifdef FEAT_SEARCH_EXTRA
!     finish_incsearch_highlighting(gotesc, &is_state, FALSE);
  #endif
  
      if (ccline.cmdbuff != NULL)
*** ../vim-8.1.0276/src/testdir/test_search.vim	2018-08-12 16:26:43.427713531 +0200
--- src/testdir/test_search.vim	2018-08-12 17:33:19.978924077 +0200
***************
*** 839,844 ****
--- 839,845 ----
    sleep 100m
  
    " Need to send one key at a time to force a redraw.
+   " Select three lines at the cursor with typed pattern.
    call term_sendkeys(buf, ':.,.+2s/')
    sleep 100m
    call term_sendkeys(buf, 'f')
***************
*** 846,852 ****
--- 847,867 ----
    call term_sendkeys(buf, 'o')
    sleep 100m
    call term_sendkeys(buf, 'o')
+   sleep 100m
    call VerifyScreenDump(buf, 'Test_incsearch_substitute_01', {})
+   call term_sendkeys(buf, "\<Esc>")
+ 
+   " Select three lines at the cursor using previous pattern.
+   call term_sendkeys(buf, "/foo\<CR>")
+   sleep 100m
+   call term_sendkeys(buf, ':.,.+2s//')
+   sleep 100m
+   call VerifyScreenDump(buf, 'Test_incsearch_substitute_02', {})
+ 
+   " Deleting last slash should remove the match.
+   call term_sendkeys(buf, "\<BS>")
+   sleep 100m
+   call VerifyScreenDump(buf, 'Test_incsearch_substitute_03', {})
  
    call term_sendkeys(buf, "\<Esc>")
    call StopVimInTerminal(buf)
*** ../vim-8.1.0276/src/testdir/dumps/Test_incsearch_substitute_02.dump	2018-08-12 17:37:49.457116653 +0200
--- src/testdir/dumps/Test_incsearch_substitute_02.dump	2018-08-12 17:02:58.756857477 +0200
***************
*** 0 ****
--- 1,9 ----
+ |f+0&#ffffff0|o@1| |1| @64
+ |f|o@1| |2| @64
+ |f|o@1| |3| @64
+ |f+1&&|o@1| +0&&|4| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|5| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|6| @64
+ |f|o@1| |7| @64
+ |f|o@1| |8| @64
+ |:|.|,|.|+|2|s|/@1> @60
*** ../vim-8.1.0276/src/testdir/dumps/Test_incsearch_substitute_03.dump	2018-08-12 17:37:49.465116598 +0200
--- src/testdir/dumps/Test_incsearch_substitute_03.dump	2018-08-12 17:33:35.062824462 +0200
***************
*** 0 ****
--- 1,9 ----
+ |f+0&#ffff4012|o@1| +0&#ffffff0|1| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|2| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|3| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|4| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|5| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|6| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|7| @64
+ |f+0&#ffff4012|o@1| +0&#ffffff0|8| @64
+ |:|.|,|.|+|2|s|/> @61
*** ../vim-8.1.0276/src/version.c	2018-08-12 16:26:43.427713531 +0200
--- src/version.c	2018-08-12 16:57:04.292430111 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     277,
  /**/

-- 
Citizens are not allowed to attend a movie house or theater nor ride in a
public streetcar within at least four hours after eating garlic.
		[real standing law in Indiana, United States of America]

 /// 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    ///