4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When shifting lines the change is acted upon multiple times.
12 Solution: Don't have shift_line() call changed_bytes.
13 Files: src/edit.c, src/ops.c, src/proto/edit.pro, src/proto/ops.pro
16 *** ../vim-7.1.230/src/edit.c Mon Jan 14 20:11:37 2008
17 --- src/edit.c Mon Jan 14 20:06:43 2008
20 * if round is TRUE, round the indent to 'shiftwidth' (only with _INC and _Dec).
23 ! change_indent(type, amount, round, replaced)
27 int replaced; /* replaced character, put on replace stack */
32 * if round is TRUE, round the indent to 'shiftwidth' (only with _INC and _Dec).
35 ! change_indent(type, amount, round, replaced, call_changed_bytes)
39 int replaced; /* replaced character, put on replace stack */
40 + int call_changed_bytes; /* call changed_bytes() */
46 * Set the new indent. The cursor will be put on the first non-blank.
48 if (type == INDENT_SET)
49 ! (void)set_indent(amount, SIN_CHANGED);
54 * Set the new indent. The cursor will be put on the first non-blank.
56 if (type == INDENT_SET)
57 ! (void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
63 if (State & VREPLACE_FLAG)
66 ! shift_line(type == INDENT_DEC, round, 1);
71 if (State & VREPLACE_FLAG)
74 ! shift_line(type == INDENT_DEC, round, 1, call_changed_bytes);
82 if (State & VREPLACE_FLAG)
83 ! change_indent(INDENT_SET, second_indent, FALSE, NUL);
86 (void)set_indent(second_indent, SIN_CHANGED);
90 if (State & VREPLACE_FLAG)
91 ! change_indent(INDENT_SET, second_indent, FALSE, NUL, TRUE);
94 (void)set_indent(second_indent, SIN_CHANGED);
97 fixthisline(get_the_indent)
98 int (*get_the_indent) __ARGS((void));
100 ! change_indent(INDENT_SET, get_the_indent(), FALSE, 0);
101 if (linewhite(curwin->w_cursor.lnum))
102 did_ai = TRUE; /* delete the indent if the line stays empty */
105 fixthisline(get_the_indent)
106 int (*get_the_indent) __ARGS((void));
108 ! change_indent(INDENT_SET, get_the_indent(), FALSE, 0, TRUE);
109 if (linewhite(curwin->w_cursor.lnum))
110 did_ai = TRUE; /* delete the indent if the line stays empty */
116 old_indent = get_indent(); /* remember curr. indent */
117 ! change_indent(INDENT_SET, 0, TRUE, 0);
120 ! change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0);
122 if (did_ai && *skipwhite(ml_get_curline()) != NUL)
127 old_indent = get_indent(); /* remember curr. indent */
128 ! change_indent(INDENT_SET, 0, TRUE, 0, TRUE);
131 ! change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE);
133 if (did_ai && *skipwhite(ml_get_curline()) != NUL)
137 curwin->w_cursor = old_pos;
139 if (State & VREPLACE_FLAG)
140 ! change_indent(INDENT_SET, i, FALSE, NUL);
143 (void)set_indent(i, SIN_CHANGED);
145 curwin->w_cursor = old_pos;
147 if (State & VREPLACE_FLAG)
148 ! change_indent(INDENT_SET, i, FALSE, NUL, TRUE);
151 (void)set_indent(i, SIN_CHANGED);
154 curwin->w_cursor = old_pos;
157 ! shift_line(TRUE, FALSE, 1);
162 curwin->w_cursor = old_pos;
165 ! shift_line(TRUE, FALSE, 1, TRUE);
169 *** ../vim-7.1.230/src/ops.c Thu Jan 3 16:31:17 2008
170 --- src/ops.c Sun Jan 13 21:52:18 2008
173 if (first_char != '#' || !preprocs_left())
176 ! shift_line(oap->op_type == OP_LSHIFT, p_sr, amount);
178 ++curwin->w_cursor.lnum;
181 if (first_char != '#' || !preprocs_left())
184 ! shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE);
186 ++curwin->w_cursor.lnum;
190 * leaves cursor on first blank in the line
193 ! shift_line(left, round, amount)
201 * leaves cursor on first blank in the line
204 ! shift_line(left, round, amount, call_changed_bytes)
208 + int call_changed_bytes; /* call changed_bytes() */
216 if (State & VREPLACE_FLAG)
217 ! change_indent(INDENT_SET, count, FALSE, NUL);
220 ! (void)set_indent(count, SIN_CHANGED);
223 #if defined(FEAT_VISUALEXTRA) || defined(PROTO)
227 if (State & VREPLACE_FLAG)
228 ! change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes);
231 ! (void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0);
234 #if defined(FEAT_VISUALEXTRA) || defined(PROTO)
235 *** ../vim-7.1.230/src/proto/edit.pro Wed Jan 2 17:48:24 2008
236 --- src/proto/edit.pro Sun Jan 13 21:52:27 2008
239 void edit_putchar __ARGS((int c, int highlight));
240 void edit_unputchar __ARGS((void));
241 void display_dollar __ARGS((colnr_T col));
242 ! void change_indent __ARGS((int type, int amount, int round, int replaced));
243 void truncate_spaces __ARGS((char_u *line));
244 void backspace_until_column __ARGS((int col));
245 int vim_is_ctrl_x_key __ARGS((int c));
247 void edit_putchar __ARGS((int c, int highlight));
248 void edit_unputchar __ARGS((void));
249 void display_dollar __ARGS((colnr_T col));
250 ! void change_indent __ARGS((int type, int amount, int round, int replaced, int call_changed_bytes));
251 void truncate_spaces __ARGS((char_u *line));
252 void backspace_until_column __ARGS((int col));
253 int vim_is_ctrl_x_key __ARGS((int c));
254 *** ../vim-7.1.230/src/proto/ops.pro Sun May 6 13:56:32 2007
255 --- src/proto/ops.pro Sun Jan 13 21:52:30 2008
258 int get_op_char __ARGS((int optype));
259 int get_extra_op_char __ARGS((int optype));
260 void op_shift __ARGS((oparg_T *oap, int curs_top, int amount));
261 ! void shift_line __ARGS((int left, int round, int amount));
262 void op_reindent __ARGS((oparg_T *oap, int (*how)(void)));
263 int get_expr_register __ARGS((void));
264 void set_expr_line __ARGS((char_u *new_line));
266 int get_op_char __ARGS((int optype));
267 int get_extra_op_char __ARGS((int optype));
268 void op_shift __ARGS((oparg_T *oap, int curs_top, int amount));
269 ! void shift_line __ARGS((int left, int round, int amount, int call_changed_bytes));
270 void op_reindent __ARGS((oparg_T *oap, int (*how)(void)));
271 int get_expr_register __ARGS((void));
272 void set_expr_line __ARGS((char_u *new_line));
273 *** ../vim-7.1.230/src/version.c Tue Jan 15 22:16:36 2008
274 --- src/version.c Wed Jan 16 19:58:25 2008
278 { /* Add new patch number below this line */
284 Snoring is prohibited unless all bedroom windows are closed and securely
286 [real standing law in Massachusetts, United States of America]
288 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
289 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
290 \\\ download, build and distribute -- http://www.A-A-P.org ///
291 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///