1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: "gH<Del>" deletes the current line, except when it's the last
13 Solution: Set the "include" flag to indicate the last line is to be deleted.
14 Files: src/normal.c, src/ops.c
17 *** ../vim-7.3.250/src/normal.c 2011-07-07 15:08:53.000000000 +0200
18 --- src/normal.c 2011-07-15 16:53:12.000000000 +0200
22 oap->inclusive = FALSE;
23 /* Try to include the newline, unless it's an operator
24 ! * that works on lines only */
26 ! && !op_on_lines(oap->op_type)
27 ! && oap->end.lnum < curbuf->b_ml.ml_line_count)
31 # ifdef FEAT_VIRTUALEDIT
32 ! oap->end.coladd = 0;
40 oap->inclusive = FALSE;
41 /* Try to include the newline, unless it's an operator
42 ! * that works on lines only. */
43 ! if (*p_sel != 'o' && !op_on_lines(oap->op_type))
45 ! if (oap->end.lnum < curbuf->b_ml.ml_line_count)
49 # ifdef FEAT_VIRTUALEDIT
50 ! oap->end.coladd = 0;
56 ! /* Cannot move below the last line, make the op
57 ! * inclusive to tell the operation to include the
59 ! oap->inclusive = TRUE;
64 *** ../vim-7.3.250/src/ops.c 2011-06-19 01:14:22.000000000 +0200
65 --- src/ops.c 2011-07-15 17:28:28.000000000 +0200
68 && oap->line_count > 1
69 && oap->op_type == OP_DELETE)
71 ! ptr = ml_get(oap->end.lnum) + oap->end.col + oap->inclusive;
73 if (*ptr == NUL && inindent(0))
74 oap->motion_type = MLINE;
76 && oap->line_count > 1
77 && oap->op_type == OP_DELETE)
79 ! ptr = ml_get(oap->end.lnum) + oap->end.col;
81 ! ptr += oap->inclusive;
83 if (*ptr == NUL && inindent(0))
84 oap->motion_type = MLINE;
87 curwin->w_cursor.coladd = 0;
90 ! (void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
96 else /* delete characters between lines */
99 curwin->w_cursor.coladd = 0;
102 ! if (oap->inclusive && oap->end.lnum == curbuf->b_ml.ml_line_count
103 ! && n > (int)STRLEN(ml_get(oap->end.lnum)))
105 ! /* Special case: gH<Del> deletes the last line. */
106 ! del_lines(1L, FALSE);
110 ! (void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
117 else /* delete characters between lines */
121 ++curwin->w_cursor.lnum;
122 del_lines((long)(oap->line_count - 2), FALSE);
124 ! /* delete from start of line until op_end */
125 ! curwin->w_cursor.col = 0;
126 ! (void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
127 ! !virtual_op, oap->op_type == OP_DELETE
132 ! curwin->w_cursor = curpos; /* restore curwin->w_cursor */
134 ! (void)do_join(2, FALSE, FALSE);
139 ++curwin->w_cursor.lnum;
140 del_lines((long)(oap->line_count - 2), FALSE);
142 ! n = (oap->end.col + 1 - !oap->inclusive);
143 ! if (oap->inclusive && oap->end.lnum == curbuf->b_ml.ml_line_count
144 ! && n > (int)STRLEN(ml_get(oap->end.lnum)))
146 ! /* Special case: gH<Del> deletes the last line. */
147 ! del_lines(1L, FALSE);
148 ! curwin->w_cursor = curpos; /* restore curwin->w_cursor */
149 ! if (curwin->w_cursor.lnum > 1)
150 ! --curwin->w_cursor.lnum;
154 ! /* delete from start of line until op_end */
155 ! curwin->w_cursor.col = 0;
156 ! (void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
161 ! curwin->w_cursor = curpos; /* restore curwin->w_cursor */
163 ! if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
164 ! (void)do_join(2, FALSE, FALSE);
168 *** ../vim-7.3.250/src/version.c 2011-07-15 15:54:39.000000000 +0200
169 --- src/version.c 2011-07-15 17:35:18.000000000 +0200
173 { /* Add new patch number below this line */
179 ### Hiroshima 45, Chernobyl 86, Windows 95 ###
181 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
182 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
183 \\\ an exciting new programming language -- http://www.Zimbu.org ///
184 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///