Skip to content

Commit 37573a2

Browse files
committed
updated for version 7.3.251
Problem: "gH<Del>" deletes the current line, except when it's the last line. Solution: Set the "include" flag to indicate the last line is to be deleted.
1 parent 44d2f39 commit 37573a2

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

src/normal.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,17 +1795,25 @@ do_pending_operator(cap, old_col, gui_yank)
17951795
{
17961796
oap->inclusive = FALSE;
17971797
/* Try to include the newline, unless it's an operator
1798-
* that works on lines only */
1799-
if (*p_sel != 'o'
1800-
&& !op_on_lines(oap->op_type)
1801-
&& oap->end.lnum < curbuf->b_ml.ml_line_count)
1798+
* that works on lines only. */
1799+
if (*p_sel != 'o' && !op_on_lines(oap->op_type))
18021800
{
1803-
++oap->end.lnum;
1804-
oap->end.col = 0;
1801+
if (oap->end.lnum < curbuf->b_ml.ml_line_count)
1802+
{
1803+
++oap->end.lnum;
1804+
oap->end.col = 0;
18051805
# ifdef FEAT_VIRTUALEDIT
1806-
oap->end.coladd = 0;
1806+
oap->end.coladd = 0;
18071807
# endif
1808-
++oap->line_count;
1808+
++oap->line_count;
1809+
}
1810+
else
1811+
{
1812+
/* Cannot move below the last line, make the op
1813+
* inclusive to tell the operation to include the
1814+
* line break. */
1815+
oap->inclusive = TRUE;
1816+
}
18091817
}
18101818
}
18111819
}

src/ops.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,9 @@ op_delete(oap)
16501650
&& oap->line_count > 1
16511651
&& oap->op_type == OP_DELETE)
16521652
{
1653-
ptr = ml_get(oap->end.lnum) + oap->end.col + oap->inclusive;
1653+
ptr = ml_get(oap->end.lnum) + oap->end.col;
1654+
if (*ptr != NUL)
1655+
ptr += oap->inclusive;
16541656
ptr = skipwhite(ptr);
16551657
if (*ptr == NUL && inindent(0))
16561658
oap->motion_type = MLINE;
@@ -1920,11 +1922,20 @@ op_delete(oap)
19201922
curwin->w_cursor.coladd = 0;
19211923
}
19221924
#endif
1923-
(void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
1925+
if (oap->inclusive && oap->end.lnum == curbuf->b_ml.ml_line_count
1926+
&& n > (int)STRLEN(ml_get(oap->end.lnum)))
1927+
{
1928+
/* Special case: gH<Del> deletes the last line. */
1929+
del_lines(1L, FALSE);
1930+
}
1931+
else
1932+
{
1933+
(void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
19241934
#ifdef FEAT_VISUAL
19251935
&& !oap->is_VIsual
19261936
#endif
19271937
);
1938+
}
19281939
}
19291940
else /* delete characters between lines */
19301941
{
@@ -1941,17 +1952,29 @@ op_delete(oap)
19411952
++curwin->w_cursor.lnum;
19421953
del_lines((long)(oap->line_count - 2), FALSE);
19431954

1944-
/* delete from start of line until op_end */
1945-
curwin->w_cursor.col = 0;
1946-
(void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
1947-
!virtual_op, oap->op_type == OP_DELETE
1955+
n = (oap->end.col + 1 - !oap->inclusive);
1956+
if (oap->inclusive && oap->end.lnum == curbuf->b_ml.ml_line_count
1957+
&& n > (int)STRLEN(ml_get(oap->end.lnum)))
1958+
{
1959+
/* Special case: gH<Del> deletes the last line. */
1960+
del_lines(1L, FALSE);
1961+
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
1962+
if (curwin->w_cursor.lnum > 1)
1963+
--curwin->w_cursor.lnum;
1964+
}
1965+
else
1966+
{
1967+
/* delete from start of line until op_end */
1968+
curwin->w_cursor.col = 0;
1969+
(void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE
19481970
#ifdef FEAT_VISUAL
19491971
&& !oap->is_VIsual
19501972
#endif
19511973
);
1952-
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
1953-
1954-
(void)do_join(2, FALSE, FALSE);
1974+
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
1975+
}
1976+
if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
1977+
(void)do_join(2, FALSE, FALSE);
19551978
}
19561979
}
19571980

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ static char *(features[]) =
709709

710710
static int included_patches[] =
711711
{ /* Add new patch number below this line */
712+
/**/
713+
251,
712714
/**/
713715
250,
714716
/**/

0 commit comments

Comments
 (0)