0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.1.2052: using "x" before a closed fold may delete that fold

Problem:    Using "x" before a closed fold may delete that fold.
Solution:   Do not translate 'x' do "dl". (Christian Brabandt, closes #4927)
This commit is contained in:
Bram Moolenaar
2019-09-17 22:42:55 +02:00
parent 705918f9f7
commit 7a9bd7c1e0
3 changed files with 23 additions and 3 deletions

View File

@@ -7381,8 +7381,8 @@ nv_optrans(cmdarg_T *cap)
if (!checkclearopq(cap->oap)) if (!checkclearopq(cap->oap))
{ {
/* In Vi "2D" doesn't delete the next line. Can't translate it // In Vi "2D" doesn't delete the next line. Can't translate it
* either, because "2." should also not use the count. */ // either, because "2." should also not use the count.
if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL)
{ {
cap->oap->start = curwin->w_cursor; cap->oap->start = curwin->w_cursor;
@@ -7400,6 +7400,12 @@ nv_optrans(cmdarg_T *cap)
{ {
if (cap->count0) if (cap->count0)
stuffnumReadbuff(cap->count0); stuffnumReadbuff(cap->count0);
// If on an empty line and using 'x' and "l" is included in the
// whichwrap option, do not delete the next line.
if (cap->cmdchar == 'x' && vim_strchr(p_ww, 'l') != NULL
&& gchar_cursor() == NUL)
stuffReadbuff((char_u *)"dd");
else
stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]);
} }
} }

View File

@@ -757,3 +757,15 @@ func Test_fold_delete_with_marker()
bwipe! bwipe!
bwipe! bwipe!
endfunc endfunc
func Test_fold_delete_with_marker_and_whichwrap()
new
let content1 = ['']
let content2 = ['folded line 1 "{{{1', ' test', ' test2', ' test3', '', 'folded line 2 "{{{1', ' test', ' test2', ' test3']
call setline(1, content1 + content2)
set fdm=marker ww+=l
normal! x
call assert_equal(content2, getline(1, '$'))
set fdm& ww&
bwipe!
endfunc

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2052,
/**/ /**/
2051, 2051,
/**/ /**/