4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When doing a block selection and using "s" to change the text,
12 while triggering auto-indenting, causes the wrong text to be
13 repeated in other lines. (Adri Verhoef)
14 Solution: Compute the change of indent and compensate for that.
18 *** ../vim-7.1.106/src/ops.c Thu Jun 28 22:14:28 2007
19 --- src/ops.c Thu Aug 30 11:41:10 2007
24 * Spaces and tabs in the indent may have changed to other spaces and
25 ! * tabs. Get the starting column again and correct the lenght.
26 * Don't do this when "$" used, end-of-line will have changed.
28 block_prep(oap, &bd2, oap->start.lnum, TRUE);
32 * Spaces and tabs in the indent may have changed to other spaces and
33 ! * tabs. Get the starting column again and correct the length.
34 * Don't do this when "$" used, end-of-line will have changed.
36 block_prep(oap, &bd2, oap->start.lnum, TRUE);
39 #ifdef FEAT_VISUALEXTRA
42 ! long ins_len, pre_textlen = 0;
44 char_u *ins_text, *newp, *oldp;
47 #ifdef FEAT_VISUALEXTRA
51 ! long pre_textlen = 0;
52 ! long pre_indent = 0;
54 char_u *ins_text, *newp, *oldp;
58 || gchar_cursor() == NUL))
59 coladvance_force(getviscol());
61 ! pre_textlen = (long)STRLEN(ml_get(oap->start.lnum));
62 bd.textcol = curwin->w_cursor.col;
66 || gchar_cursor() == NUL))
67 coladvance_force(getviscol());
69 ! firstline = ml_get(oap->start.lnum);
70 ! pre_textlen = (long)STRLEN(firstline);
71 ! pre_indent = (long)(skipwhite(firstline) - firstline);
72 bd.textcol = curwin->w_cursor.col;
78 if (oap->block_mode && oap->start.lnum != oap->end.lnum)
80 firstline = ml_get(oap->start.lnum);
82 ! * Subsequent calls to ml_get() flush the firstline data - take a
83 ! * copy of the required bit.
85 ! if ((ins_len = (long)STRLEN(firstline) - pre_textlen) > 0)
87 if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL)
89 vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
92 if (oap->block_mode && oap->start.lnum != oap->end.lnum)
94 + /* Auto-indenting may have changed the indent. If the cursor was past
95 + * the indent, exclude that indent change from the inserted text. */
96 firstline = ml_get(oap->start.lnum);
97 ! if (bd.textcol > pre_indent)
99 ! long new_indent = (long)(skipwhite(firstline) - firstline);
101 ! pre_textlen += new_indent - pre_indent;
102 ! bd.textcol += new_indent - pre_indent;
105 ! ins_len = (long)STRLEN(firstline) - pre_textlen;
108 + /* Subsequent calls to ml_get() flush the firstline data - take a
109 + * copy of the inserted text. */
110 if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL)
112 vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
113 *** ../vim-7.1.106/src/version.c Thu Sep 13 22:04:30 2007
114 --- src/version.c Thu Sep 13 22:38:28 2007
118 { /* Add new patch number below this line */
127 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
128 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
129 \\\ download, build and distribute -- http://www.A-A-P.org ///
130 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///