]> git.pld-linux.org Git - packages/vim.git/blame - 7.1.038
- updated to 7.1.285
[packages/vim.git] / 7.1.038
CommitLineData
6577e359 1To: vim-dev@vim.org
2Subject: patch 7.1.038
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.1.038
11Problem: When 'expandtab' is set then a Tab copied for 'copyindent' is
12 expanded to spaces, even when 'preserveindent' is set. (Alexei
13 Alexandrov)
14Solution: Remove the check for 'expandtab'. Also fix that ">>" doesn't obey
15 'preserveindent'. (Chris Lubinski)
16Files: src/misc1.c
17
18
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
21***************
22*** 90,96 ****
23 */
24 int
25 set_indent(size, flags)
26! int size;
27 int flags;
28 {
29 char_u *p;
30--- 90,96 ----
31 */
32 int
33 set_indent(size, flags)
34! int size; /* measured in spaces */
35 int flags;
36 {
37 char_u *p;
38***************
39*** 98,109 ****
40 char_u *oldline;
41 char_u *s;
42 int todo;
43! int ind_len;
44 int line_len;
45 int doit = FALSE;
46! int ind_done;
47 int tab_pad;
48 int retval = FALSE;
49
50 /*
51 * First check if there is anything to do and compute the number of
52--- 98,111 ----
53 char_u *oldline;
54 char_u *s;
55 int todo;
56! int ind_len; /* measured in characters */
57 int line_len;
58 int doit = FALSE;
59! int ind_done = 0; /* measured in spaces */
60 int tab_pad;
61 int retval = FALSE;
62+ int orig_char_len = 0; /* number of initial whitespace chars when
63+ 'et' and 'pi' are both set */
64
65 /*
66 * First check if there is anything to do and compute the number of
67***************
68*** 116,123 ****
69 /* Calculate the buffer size for the new indent, and check to see if it
70 * isn't already set */
71
72! /* if 'expandtab' isn't set: use TABs */
73! if (!curbuf->b_p_et)
74 {
75 /* If 'preserveindent' is set then reuse as much as possible of
76 * the existing indent structure for the new indent */
77--- 118,127 ----
78 /* Calculate the buffer size for the new indent, and check to see if it
79 * isn't already set */
80
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))
85 {
86 /* If 'preserveindent' is set then reuse as much as possible of
87 * the existing indent structure for the new indent */
88***************
89*** 148,156 ****
90 ++p;
91 }
92
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)
96 {
97 doit = TRUE;
98 todo -= tab_pad;
99--- 152,165 ----
100 ++p;
101 }
102
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;
107+
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)
111 {
112 doit = TRUE;
113 todo -= tab_pad;
114***************
115*** 193,205 ****
116 else
117 p = skipwhite(p);
118 line_len = (int)STRLEN(p) + 1;
119! newline = alloc(ind_len + line_len);
120! if (newline == NULL)
121! return FALSE;
122
123 /* Put the characters in the new line. */
124- s = newline;
125- todo = size;
126 /* if 'expandtab' isn't set: use TABs */
127 if (!curbuf->b_p_et)
128 {
129--- 202,239 ----
130 else
131 p = skipwhite(p);
132 line_len = (int)STRLEN(p) + 1;
133!
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)
138! {
139! newline = alloc(orig_char_len + size - ind_done + line_len);
140! if (newline == NULL)
141! return FALSE;
142! p = oldline;
143! s = newline;
144! while (orig_char_len > 0)
145! {
146! *s++ = *p++;
147! orig_char_len--;
148! }
149! /* Skip over any additional white space (useful when newindent is less
150! * than old) */
151! while (vim_iswhite(*p))
152! (void)*p++;
153! todo = size-ind_done;
154! }
155! else
156! {
157! todo = size;
158! newline = alloc(ind_len + line_len);
159! if (newline == NULL)
160! return FALSE;
161! s = newline;
162! }
163
164 /* Put the characters in the new line. */
165 /* if 'expandtab' isn't set: use TABs */
166 if (!curbuf->b_p_et)
167 {
168***************
169*** 1320,1327 ****
170 newindent += (int)curbuf->b_p_sw;
171 }
172 #endif
173! /* Copy the indent only if expand tab is disabled */
174! if (curbuf->b_p_ci && !curbuf->b_p_et)
175 {
176 (void)copy_indent(newindent, saved_line);
177
178--- 1354,1361 ----
179 newindent += (int)curbuf->b_p_sw;
180 }
181 #endif
182! /* Copy the indent */
183! if (curbuf->b_p_ci)
184 {
185 (void)copy_indent(newindent, saved_line);
186
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
189***************
190*** 668,669 ****
191--- 668,671 ----
192 { /* Add new patch number below this line */
193+ /**/
194+ 38,
195 /**/
196
197--
198Time is an illusion. Lunchtime doubly so.
199 -- Ford Prefect, in Douglas Adams'
200 "The Hitchhiker's Guide to the Galaxy"
201
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 ///
This page took 0.040149 seconds and 4 git commands to generate.