4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When 'expandtab' is set then a Tab copied for 'copyindent' is
12 expanded to spaces, even when 'preserveindent' is set. (Alexei
14 Solution: Remove the check for 'expandtab'. Also fix that ">>" doesn't obey
15 'preserveindent'. (Chris Lubinski)
19 *** ../vim-7.1.037/src/misc1.c Thu May 10 21:03:33 2007
20 --- src/misc1.c Tue Jul 24 15:24:50 2007
25 set_indent(size, flags)
33 set_indent(size, flags)
34 ! int size; /* measured in spaces */
51 * First check if there is anything to do and compute the number of
56 ! int ind_len; /* measured in characters */
59 ! int ind_done = 0; /* measured in spaces */
62 + int orig_char_len = 0; /* number of initial whitespace chars when
63 + 'et' and 'pi' are both set */
66 * First check if there is anything to do and compute the number of
69 /* Calculate the buffer size for the new indent, and check to see if it
70 * isn't already set */
72 ! /* if 'expandtab' isn't set: use TABs */
73 ! if (!curbuf->b_p_et)
75 /* If 'preserveindent' is set then reuse as much as possible of
76 * the existing indent structure for the new indent */
78 /* Calculate the buffer size for the new indent, and check to see if it
79 * isn't already set */
81 ! /* if 'expandtab' isn't set: use TABs; if both 'expandtab' and
82 ! * 'preserveindent' are set count the number of characters at the
83 ! * beginning of the line to be copied */
84 ! if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi))
86 /* If 'preserveindent' is set then reuse as much as possible of
87 * the existing indent structure for the new indent */
93 /* Fill to next tabstop with a tab, if possible */
94 tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
95 ! if (todo >= tab_pad)
103 + /* Set initial number of whitespace chars to copy if we are
104 + * preserving indent but expandtab is set */
105 + if (curbuf->b_p_et)
106 + orig_char_len = ind_len;
108 /* Fill to next tabstop with a tab, if possible */
109 tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
110 ! if (todo >= tab_pad && orig_char_len == 0)
118 line_len = (int)STRLEN(p) + 1;
119 ! newline = alloc(ind_len + line_len);
120 ! if (newline == NULL)
123 /* Put the characters in the new line. */
126 /* if 'expandtab' isn't set: use TABs */
132 line_len = (int)STRLEN(p) + 1;
134 ! /* If 'preserveindent' and 'expandtab' are both set keep the original
135 ! * characters and allocate accordingly. We will fill the rest with spaces
136 ! * after the if (!curbuf->b_p_et) below. */
137 ! if (orig_char_len != 0)
139 ! newline = alloc(orig_char_len + size - ind_done + line_len);
140 ! if (newline == NULL)
144 ! while (orig_char_len > 0)
149 ! /* Skip over any additional white space (useful when newindent is less
151 ! while (vim_iswhite(*p))
153 ! todo = size-ind_done;
158 ! newline = alloc(ind_len + line_len);
159 ! if (newline == NULL)
164 /* Put the characters in the new line. */
165 /* if 'expandtab' isn't set: use TABs */
170 newindent += (int)curbuf->b_p_sw;
173 ! /* Copy the indent only if expand tab is disabled */
174 ! if (curbuf->b_p_ci && !curbuf->b_p_et)
176 (void)copy_indent(newindent, saved_line);
179 newindent += (int)curbuf->b_p_sw;
182 ! /* Copy the indent */
183 ! if (curbuf->b_p_ci)
185 (void)copy_indent(newindent, saved_line);
187 *** ../vim-7.1.037/src/version.c Tue Jul 24 14:57:16 2007
188 --- src/version.c Tue Jul 24 15:22:44 2007
192 { /* Add new patch number below this line */
198 Time is an illusion. Lunchtime doubly so.
199 -- Ford Prefect, in Douglas Adams'
200 "The Hitchhiker's Guide to the Galaxy"
202 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
203 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
204 \\\ download, build and distribute -- http://www.A-A-P.org ///
205 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///