]>
Commit | Line | Data |
---|---|---|
8bb52fd3 ER |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.576 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.576 | |
11 | Problem: Formatting of lists inside comments is not right yet. | |
12 | Solution: Use another solution and add a test. (Tor Perkins) | |
13 | Files: src/edit.c, src/misc1.c, src/testdir/test68.in, | |
14 | src/testdir/test69.ok | |
15 | ||
16 | ||
17 | *** ../vim-7.3.575/src/edit.c 2012-06-20 22:55:56.000000000 +0200 | |
18 | --- src/edit.c 2012-06-29 14:10:36.000000000 +0200 | |
19 | *************** | |
20 | *** 6320,6333 **** | |
21 | if (!(flags & INSCHAR_COM_LIST)) | |
22 | { | |
23 | /* | |
24 | ! * This section is for numeric lists w/o comments. If comment | |
25 | ! * indents are needed with numeric lists (formatoptions=nq), | |
26 | ! * then the INSCHAR_COM_LIST flag will cause the corresponding | |
27 | ! * OPENLINE_COM_LIST flag to be passed through to open_line() | |
28 | ! * (as seen above)... | |
29 | */ | |
30 | if (second_indent < 0 && has_format_option(FO_Q_NUMBER)) | |
31 | ! second_indent = get_number_indent(curwin->w_cursor.lnum -1); | |
32 | if (second_indent >= 0) | |
33 | { | |
34 | #ifdef FEAT_VREPLACE | |
35 | --- 6320,6334 ---- | |
36 | if (!(flags & INSCHAR_COM_LIST)) | |
37 | { | |
38 | /* | |
39 | ! * This section is for auto-wrap of numeric lists. When not | |
40 | ! * in insert mode (i.e. format_lines()), the INSCHAR_COM_LIST | |
41 | ! * flag will be set and open_line() will handle it (as seen | |
42 | ! * above). The code here (and in get_number_indent()) will | |
43 | ! * recognize comments if needed... | |
44 | */ | |
45 | if (second_indent < 0 && has_format_option(FO_Q_NUMBER)) | |
46 | ! second_indent = | |
47 | ! get_number_indent(curwin->w_cursor.lnum - 1); | |
48 | if (second_indent >= 0) | |
49 | { | |
50 | #ifdef FEAT_VREPLACE | |
51 | *************** | |
52 | *** 6336,6342 **** | |
53 | --- 6337,6367 ---- | |
54 | FALSE, NUL, TRUE); | |
55 | else | |
56 | #endif | |
57 | + #ifdef FEAT_COMMENTS | |
58 | + if (leader_len > 0 && second_indent - leader_len > 0) | |
59 | + { | |
60 | + int i; | |
61 | + int padding = second_indent - leader_len; | |
62 | + | |
63 | + /* We started at the first_line of a numbered list | |
64 | + * that has a comment. the open_line() function has | |
65 | + * inserted the proper comment leader and positioned | |
66 | + * the cursor at the end of the split line. Now we | |
67 | + * add the additional whitespace needed after the | |
68 | + * comment leader for the numbered list. */ | |
69 | + for (i = 0; i < padding; i++) | |
70 | + { | |
71 | + ins_str((char_u *)" "); | |
72 | + changed_bytes(curwin->w_cursor.lnum, leader_len); | |
73 | + } | |
74 | + } | |
75 | + else | |
76 | + { | |
77 | + #endif | |
78 | (void)set_indent(second_indent, SIN_CHANGED); | |
79 | + #ifdef FEAT_COMMENTS | |
80 | + } | |
81 | + #endif | |
82 | } | |
83 | } | |
84 | first_line = FALSE; | |
85 | *** ../vim-7.3.575/src/misc1.c 2012-06-20 17:56:06.000000000 +0200 | |
86 | --- src/misc1.c 2012-06-29 14:10:12.000000000 +0200 | |
87 | *************** | |
88 | *** 424,491 **** | |
89 | colnr_T col; | |
90 | pos_T pos; | |
91 | ||
92 | if (lnum > curbuf->b_ml.ml_line_count) | |
93 | return -1; | |
94 | pos.lnum = 0; | |
95 | ||
96 | #ifdef FEAT_COMMENTS | |
97 | ! if (has_format_option(FO_Q_COMS) && has_format_option(FO_Q_NUMBER)) | |
98 | ! { | |
99 | ! regmatch_T regmatch; | |
100 | ! int lead_len; /* length of comment leader */ | |
101 | ! | |
102 | lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE); | |
103 | - regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); | |
104 | - if (regmatch.regprog != NULL) | |
105 | - { | |
106 | - regmatch.rm_ic = FALSE; | |
107 | - | |
108 | - /* vim_regexec() expects a pointer to a line. This lets us | |
109 | - * start matching for the flp beyond any comment leader... */ | |
110 | - if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0)) | |
111 | - { | |
112 | - pos.lnum = lnum; | |
113 | - pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum)); | |
114 | - #ifdef FEAT_VIRTUALEDIT | |
115 | - pos.coladd = 0; | |
116 | #endif | |
117 | ! } | |
118 | ! } | |
119 | ! vim_free(regmatch.regprog); | |
120 | ! } | |
121 | ! else | |
122 | { | |
123 | ! /* | |
124 | ! * What follows is the orig code that is not "comment aware"... | |
125 | ! * | |
126 | ! * I'm not sure if regmmatch_T (multi-match) is needed in this case. | |
127 | ! * It may be true that this section would work properly using the | |
128 | ! * regmatch_T code above, in which case, these two separate sections | |
129 | ! * should be consolidated w/ FEAT_COMMENTS making lead_len > 0... | |
130 | ! */ | |
131 | ! #endif | |
132 | ! regmmatch_T regmatch; | |
133 | ||
134 | ! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); | |
135 | ! | |
136 | ! if (regmatch.regprog != NULL) | |
137 | { | |
138 | ! regmatch.rmm_ic = FALSE; | |
139 | ! regmatch.rmm_maxcol = 0; | |
140 | ! if (vim_regexec_multi(®match, curwin, curbuf, | |
141 | ! lnum, (colnr_T)0, NULL)) | |
142 | ! { | |
143 | ! pos.lnum = regmatch.endpos[0].lnum + lnum; | |
144 | ! pos.col = regmatch.endpos[0].col; | |
145 | #ifdef FEAT_VIRTUALEDIT | |
146 | ! pos.coladd = 0; | |
147 | #endif | |
148 | - } | |
149 | - vim_free(regmatch.regprog); | |
150 | } | |
151 | - #ifdef FEAT_COMMENTS | |
152 | } | |
153 | ! #endif | |
154 | ||
155 | if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL) | |
156 | return -1; | |
157 | --- 424,458 ---- | |
158 | colnr_T col; | |
159 | pos_T pos; | |
160 | ||
161 | + regmatch_T regmatch; | |
162 | + int lead_len = 0; /* length of comment leader */ | |
163 | + | |
164 | if (lnum > curbuf->b_ml.ml_line_count) | |
165 | return -1; | |
166 | pos.lnum = 0; | |
167 | ||
168 | #ifdef FEAT_COMMENTS | |
169 | ! /* In format_lines() (i.e. not insert mode), fo+=q is needed too... */ | |
170 | ! if ((State & INSERT) || has_format_option(FO_Q_COMS)) | |
171 | lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE); | |
172 | #endif | |
173 | ! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); | |
174 | ! if (regmatch.regprog != NULL) | |
175 | { | |
176 | ! regmatch.rm_ic = FALSE; | |
177 | ||
178 | ! /* vim_regexec() expects a pointer to a line. This lets us | |
179 | ! * start matching for the flp beyond any comment leader... */ | |
180 | ! if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0)) | |
181 | { | |
182 | ! pos.lnum = lnum; | |
183 | ! pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum)); | |
184 | #ifdef FEAT_VIRTUALEDIT | |
185 | ! pos.coladd = 0; | |
186 | #endif | |
187 | } | |
188 | } | |
189 | ! vim_free(regmatch.regprog); | |
190 | ||
191 | if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL) | |
192 | return -1; | |
193 | *** ../vim-7.3.575/src/testdir/test68.in 2012-06-13 17:28:51.000000000 +0200 | |
194 | --- src/testdir/test68.in 2012-06-29 14:27:27.000000000 +0200 | |
195 | *************** | |
196 | *** 52,57 **** | |
197 | --- 52,68 ---- | |
198 | ||
199 | STARTTEST | |
200 | /^{/+1 | |
201 | + :set tw=5 fo=tcn comments=:# | |
202 | + A b\ejA b\e | |
203 | + ENDTEST | |
204 | + | |
205 | + { | |
206 | + 1 a | |
207 | + # 1 a | |
208 | + } | |
209 | + | |
210 | + STARTTEST | |
211 | + /^{/+1 | |
212 | :set tw=5 fo=qn comments=:# | |
213 | gwap | |
214 | ENDTEST | |
215 | *************** | |
216 | *** 83,88 **** | |
217 | --- 94,107 ---- | |
218 | } | |
219 | ||
220 | STARTTEST | |
221 | + /^#/ | |
222 | + :setl tw=12 fo=tqnc comments=:# | |
223 | + A foobar\e | |
224 | + ENDTEST | |
225 | + | |
226 | + # 1 xxxxx | |
227 | + | |
228 | + STARTTEST | |
229 | :g/^STARTTEST/.,/^ENDTEST/d | |
230 | :1;/^Results/,$wq! test.out | |
231 | ENDTEST | |
232 | *** ../vim-7.3.575/src/version.c 2012-06-29 13:56:01.000000000 +0200 | |
233 | --- src/version.c 2012-06-29 15:03:10.000000000 +0200 | |
234 | *************** | |
235 | *** 716,717 **** | |
236 | --- 716,719 ---- | |
237 | { /* Add new patch number below this line */ | |
238 | + /**/ | |
239 | + 576, | |
240 | /**/ | |
241 | ||
242 | -- | |
243 | Proof techniques #2: Proof by Oddity. | |
244 | SAMPLE: To prove that horses have an infinite number of legs. | |
245 | (1) Horses have an even number of legs. | |
246 | (2) They have two legs in back and fore legs in front. | |
247 | (3) This makes a total of six legs, which certainly is an odd number of | |
248 | legs for a horse. | |
249 | (4) But the only number that is both odd and even is infinity. | |
250 | (5) Therefore, horses must have an infinite number of legs. | |
251 | ||
252 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
253 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
254 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
255 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |