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
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0126
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.0126
Problem: Various problems with 'vartabstop'.
Solution: Fix memory leak. Fix crash. Add a few more tests. (Christian
Brabandt, closes #3076)
Files: src/ex_cmds.c, src/option.c, src/screen.c,
src/testdir/test_vartabs.vim
*** ../vim-8.1.0125/src/ex_cmds.c 2018-06-28 11:28:04.793455550 +0200
--- src/ex_cmds.c 2018-06-28 20:37:11.354721386 +0200
***************
*** 866,872 ****
{
set_string_option_direct((char_u *)"vts", -1, new_ts_str,
OPT_FREE|OPT_LOCAL, 0);
- vim_free(new_ts_str);
curbuf->b_p_vts_array = new_vts_array;
vim_free(old_vts_ary);
}
--- 866,871 ----
***************
*** 877,882 ****
--- 876,882 ----
curbuf->b_p_ts = tabstop_first(new_vts_array);
vim_free(new_vts_array);
}
+ vim_free(new_ts_str);
}
#else
curbuf->b_p_ts = new_ts;
*** ../vim-8.1.0125/src/option.c 2018-06-28 15:29:48.081656098 +0200
--- src/option.c 2018-06-28 20:40:51.173370370 +0200
***************
*** 12870,12876 ****
tabstop_fromto(
colnr_T start_col,
colnr_T end_col,
! int ts,
int *vts,
int *ntabs,
int *nspcs)
--- 12870,12876 ----
tabstop_fromto(
colnr_T start_col,
colnr_T end_col,
! int ts_arg,
int *vts,
int *ntabs,
int *nspcs)
***************
*** 12880,12891 ****
int padding = 0;
int tabcount;
int t;
if (vts == NULL || vts[0] == 0)
{
int tabs = 0;
! int initspc = ts - (start_col % ts);
if (spaces >= initspc)
{
spaces -= initspc;
--- 12880,12893 ----
int padding = 0;
int tabcount;
int t;
+ int ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg;
if (vts == NULL || vts[0] == 0)
{
int tabs = 0;
! int initspc = 0;
+ initspc = ts - (start_col % ts);
if (spaces >= initspc)
{
spaces -= initspc;
*** ../vim-8.1.0125/src/screen.c 2018-06-25 21:24:47.284934379 +0200
--- src/screen.c 2018-06-28 20:38:50.538108113 +0200
***************
*** 4753,4765 ****
n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
NULL) - 1;
if (c == TAB && n_extra + col > wp->w_width)
! #ifdef FEAT_VARTABS
n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts,
! wp->w_buffer->b_p_vts_array) - 1;
! #else
n_extra = (int)wp->w_buffer->b_p_ts
- vcol % (int)wp->w_buffer->b_p_ts - 1;
! #endif
# ifdef FEAT_MBYTE
c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' ';
--- 4753,4765 ----
n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
NULL) - 1;
if (c == TAB && n_extra + col > wp->w_width)
! # ifdef FEAT_VARTABS
n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts,
! wp->w_buffer->b_p_vts_array) - 1;
! # else
n_extra = (int)wp->w_buffer->b_p_ts
- vcol % (int)wp->w_buffer->b_p_ts - 1;
! # endif
# ifdef FEAT_MBYTE
c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' ';
***************
*** 4902,4907 ****
--- 4902,4912 ----
p_extra_free = p;
for (i = 0; i < tab_len; i++)
{
+ if (*p == NUL)
+ {
+ tab_len = i;
+ break;
+ }
#ifdef FEAT_MBYTE
mb_char2bytes(lcs_tab2, p);
p += mb_char2len(lcs_tab2);
*** ../vim-8.1.0125/src/testdir/test_vartabs.vim 2018-06-25 21:24:47.284934379 +0200
--- src/testdir/test_vartabs.vim 2018-06-28 20:42:19.772833210 +0200
***************
*** 262,282 ****
endfunc
func! Test_vartabs_linebreak()
! if winwidth(0) < 80
return
endif
new
! 70vnew
%d
! setl linebreak vartabstop=10,15,20,40
call setline(1, "\tx\tx\tx\tx")
! let lines = ScreenLines([1, 2], winwidth(0))
! let expect = [' x x x ',
! \ ' x ']
call s:compare_lines(expect, lines)
" cleanup
bw!
bw!
endfunc
--- 262,298 ----
endfunc
func! Test_vartabs_linebreak()
! if winwidth(0) < 40
return
endif
new
! 40vnew
%d
! setl linebreak vartabstop=10,20,30,40
call setline(1, "\tx\tx\tx\tx")
! let expect = [' x ',
! \ 'x x ',
! \ 'x ']
! let lines = ScreenLines([1, 3], winwidth(0))
! call s:compare_lines(expect, lines)
! setl list listchars=tab:>-
! let expect = ['>---------x>------------------ ',
! \ 'x>------------------x>------------------',
! \ 'x ']
! let lines = ScreenLines([1, 3], winwidth(0))
! call s:compare_lines(expect, lines)
! setl linebreak vartabstop=40
! let expect = ['>---------------------------------------',
! \ 'x>--------------------------------------',
! \ 'x>--------------------------------------',
! \ 'x>--------------------------------------',
! \ 'x ']
! let lines = ScreenLines([1, 5], winwidth(0))
call s:compare_lines(expect, lines)
" cleanup
bw!
bw!
+ set nolist listchars&vim
endfunc
*** ../vim-8.1.0125/src/version.c 2018-06-28 19:26:24.321655175 +0200
--- src/version.c 2018-06-28 20:36:19.043047749 +0200
***************
*** 791,792 ****
--- 791,794 ----
{ /* Add new patch number below this line */
+ /**/
+ 126,
/**/
--
hundred-and-one symptoms of being an internet addict:
138. You develop a liking for cold coffee.
/// 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 ///
|