summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0061
blob: e9c537e67234a50204a9f23b922ecb116b83f8c4 (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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0061
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.0061
Problem:    Window title is wrong after resetting and setting 'title'.
Solution:   Move resetting the title into maketitle(). (Jason Franklin)
Files:	    src/option.c, src/buffer.c


*** ../vim-8.1.0060/src/option.c	2018-06-12 16:49:26.366028607 +0200
--- src/option.c	2018-06-16 22:36:07.814142229 +0200
***************
*** 3256,3264 ****
  #ifdef FEAT_CMDWIN
  static char_u *check_cedit(void);
  #endif
- #ifdef FEAT_TITLE
- static void did_set_title(int icon);
- #endif
  static char_u *option_expand(int opt_idx, char_u *val);
  static void didset_options(void);
  static void didset_options2(void);
--- 3256,3261 ----
***************
*** 5374,5400 ****
   * the old value back.
   */
      static void
! did_set_title(
!     int	    icon)	    /* Did set icon instead of title */
  {
      if (starting != NO_SCREEN
  #ifdef FEAT_GUI
  	    && !gui.starting
  #endif
  				)
-     {
  	maketitle();
- 	if (icon)
- 	{
- 	    if (!p_icon)
- 		mch_restore_title(2);
- 	}
- 	else
- 	{
- 	    if (!p_title)
- 		mch_restore_title(1);
- 	}
-     }
  }
  #endif
  
--- 5371,5384 ----
   * the old value back.
   */
      static void
! did_set_title(void)
  {
      if (starting != NO_SCREEN
  #ifdef FEAT_GUI
  	    && !gui.starting
  #endif
  				)
  	maketitle();
  }
  #endif
  
***************
*** 6949,6956 ****
  	else
  	    stl_syntax &= ~flagval;
  # endif
! 	did_set_title(varp == &p_iconstring);
! 
      }
  #endif
  
--- 6933,6939 ----
  	else
  	    stl_syntax &= ~flagval;
  # endif
! 	did_set_title();
      }
  #endif
  
***************
*** 8401,8414 ****
  
  #ifdef FEAT_TITLE
      /* when 'title' changed, may need to change the title; same for 'icon' */
!     else if ((int *)varp == &p_title)
!     {
! 	did_set_title(FALSE);
!     }
! 
!     else if ((int *)varp == &p_icon)
      {
! 	did_set_title(TRUE);
      }
  #endif
  
--- 8384,8392 ----
  
  #ifdef FEAT_TITLE
      /* when 'title' changed, may need to change the title; same for 'icon' */
!     else if ((int *)varp == &p_title || (int *)varp == &p_icon)
      {
! 	did_set_title();
      }
  #endif
  
*** ../vim-8.1.0060/src/buffer.c	2018-06-06 18:02:31.402773772 +0200
--- src/buffer.c	2018-06-16 22:57:08.067368623 +0200
***************
*** 38,44 ****
  static int	otherfile_buf(buf_T *buf, char_u *ffname);
  #endif
  #ifdef FEAT_TITLE
! static int	ti_change(char_u *str, char_u **last);
  #endif
  static int	append_arg_number(win_T *wp, char_u *buf, int buflen, int add_file);
  static void	free_buffer(buf_T *);
--- 38,44 ----
  static int	otherfile_buf(buf_T *buf, char_u *ffname);
  #endif
  #ifdef FEAT_TITLE
! static int	value_changed(char_u *str, char_u **last);
  #endif
  static int	append_arg_number(win_T *wp, char_u *buf, int buflen, int add_file);
  static void	free_buffer(buf_T *);
***************
*** 3545,3564 ****
  }
  
  #if defined(FEAT_TITLE) || defined(PROTO)
- /*
-  * put file name in title bar of window and in icon title
-  */
- 
  static char_u *lasttitle = NULL;
  static char_u *lasticon = NULL;
  
      void
  maketitle(void)
  {
      char_u	*p;
!     char_u	*t_str = NULL;
!     char_u	*i_name;
!     char_u	*i_str = NULL;
      int		maxlen = 0;
      int		len;
      int		mustset;
--- 3545,3562 ----
  }
  
  #if defined(FEAT_TITLE) || defined(PROTO)
  static char_u *lasttitle = NULL;
  static char_u *lasticon = NULL;
  
+ /*
+  * Put the file name in the title bar and icon of the window.
+  */
      void
  maketitle(void)
  {
      char_u	*p;
!     char_u	*title_str = NULL;
!     char_u	*icon_str = NULL;
      int		maxlen = 0;
      int		len;
      int		mustset;
***************
*** 3574,3580 ****
  
      need_maketitle = FALSE;
      if (!p_title && !p_icon && lasttitle == NULL && lasticon == NULL)
! 	return;
  
      if (p_title)
      {
--- 3572,3578 ----
  
      need_maketitle = FALSE;
      if (!p_title && !p_icon && lasttitle == NULL && lasticon == NULL)
! 	return;  // nothing to do
  
      if (p_title)
      {
***************
*** 3585,3591 ****
  		maxlen = 10;
  	}
  
! 	t_str = buf;
  	if (*p_titlestring != NUL)
  	{
  #ifdef FEAT_STL_OPT
--- 3583,3589 ----
  		maxlen = 10;
  	}
  
! 	title_str = buf;
  	if (*p_titlestring != NUL)
  	{
  #ifdef FEAT_STL_OPT
***************
*** 3598,3604 ****
  		use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
  # endif
  		called_emsg = FALSE;
! 		build_stl_str_hl(curwin, t_str, sizeof(buf),
  					      p_titlestring, use_sandbox,
  					      0, maxlen, NULL, NULL);
  		if (called_emsg)
--- 3596,3602 ----
  		use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
  # endif
  		called_emsg = FALSE;
! 		build_stl_str_hl(curwin, title_str, sizeof(buf),
  					      p_titlestring, use_sandbox,
  					      0, maxlen, NULL, NULL);
  		if (called_emsg)
***************
*** 3608,3614 ****
  	    }
  	    else
  #endif
! 		t_str = p_titlestring;
  	}
  	else
  	{
--- 3606,3612 ----
  	    }
  	    else
  #endif
! 		title_str = p_titlestring;
  	}
  	else
  	{
***************
*** 3714,3724 ****
  	    }
  	}
      }
!     mustset = ti_change(t_str, &lasttitle);
  
      if (p_icon)
      {
! 	i_str = buf;
  	if (*p_iconstring != NUL)
  	{
  #ifdef FEAT_STL_OPT
--- 3712,3722 ----
  	    }
  	}
      }
!     mustset = value_changed(title_str, &lasttitle);
  
      if (p_icon)
      {
! 	icon_str = buf;
  	if (*p_iconstring != NUL)
  	{
  #ifdef FEAT_STL_OPT
***************
*** 3731,3737 ****
  		use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
  # endif
  		called_emsg = FALSE;
! 		build_stl_str_hl(curwin, i_str, sizeof(buf),
  						    p_iconstring, use_sandbox,
  						    0, 0, NULL, NULL);
  		if (called_emsg)
--- 3729,3735 ----
  		use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
  # endif
  		called_emsg = FALSE;
! 		build_stl_str_hl(curwin, icon_str, sizeof(buf),
  						    p_iconstring, use_sandbox,
  						    0, 0, NULL, NULL);
  		if (called_emsg)
***************
*** 3741,3772 ****
  	    }
  	    else
  #endif
! 		i_str = p_iconstring;
  	}
  	else
  	{
  	    if (buf_spname(curbuf) != NULL)
! 		i_name = buf_spname(curbuf);
  	    else		    /* use file name only in icon */
! 		i_name = gettail(curbuf->b_ffname);
! 	    *i_str = NUL;
  	    /* Truncate name at 100 bytes. */
! 	    len = (int)STRLEN(i_name);
  	    if (len > 100)
  	    {
  		len -= 100;
  #ifdef FEAT_MBYTE
  		if (has_mbyte)
! 		    len += (*mb_tail_off)(i_name, i_name + len) + 1;
  #endif
! 		i_name += len;
  	    }
! 	    STRCPY(i_str, i_name);
! 	    trans_characters(i_str, IOSIZE);
  	}
      }
  
!     mustset |= ti_change(i_str, &lasticon);
  
      if (mustset)
  	resettitle();
--- 3739,3770 ----
  	    }
  	    else
  #endif
! 		icon_str = p_iconstring;
  	}
  	else
  	{
  	    if (buf_spname(curbuf) != NULL)
! 		p = buf_spname(curbuf);
  	    else		    /* use file name only in icon */
! 		p = gettail(curbuf->b_ffname);
! 	    *icon_str = NUL;
  	    /* Truncate name at 100 bytes. */
! 	    len = (int)STRLEN(p);
  	    if (len > 100)
  	    {
  		len -= 100;
  #ifdef FEAT_MBYTE
  		if (has_mbyte)
! 		    len += (*mb_tail_off)(p, p + len) + 1;
  #endif
! 		p += len;
  	    }
! 	    STRCPY(icon_str, p);
! 	    trans_characters(icon_str, IOSIZE);
  	}
      }
  
!     mustset |= value_changed(icon_str, &lasticon);
  
      if (mustset)
  	resettitle();
***************
*** 3775,3794 ****
  /*
   * Used for title and icon: Check if "str" differs from "*last".  Set "*last"
   * from "str" if it does.
!  * Return TRUE when "*last" changed.
   */
      static int
! ti_change(char_u *str, char_u **last)
  {
      if ((str == NULL) != (*last == NULL)
  	    || (str != NULL && *last != NULL && STRCMP(str, *last) != 0))
      {
  	vim_free(*last);
  	if (str == NULL)
  	    *last = NULL;
  	else
  	    *last = vim_strsave(str);
! 	return TRUE;
      }
      return FALSE;
  }
--- 3773,3797 ----
  /*
   * Used for title and icon: Check if "str" differs from "*last".  Set "*last"
   * from "str" if it does.
!  * Return TRUE if resettitle() is to be called.
   */
      static int
! value_changed(char_u *str, char_u **last)
  {
      if ((str == NULL) != (*last == NULL)
  	    || (str != NULL && *last != NULL && STRCMP(str, *last) != 0))
      {
  	vim_free(*last);
  	if (str == NULL)
+ 	{
  	    *last = NULL;
+ 	    mch_restore_title(last == &lasttitle ? 1 : 2);
+ 	}
  	else
+ 	{
  	    *last = vim_strsave(str);
! 	    return TRUE;
! 	}
      }
      return FALSE;
  }
*** ../vim-8.1.0060/src/version.c	2018-06-16 22:16:43.232576946 +0200
--- src/version.c	2018-06-16 22:48:20.082215622 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     61,
  /**/

-- 
"I don’t know how to make a screenshot" - Richard Stallman, July 2002
(when asked to send a screenshot of his desktop for unix.se)

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