From 97b82553e09b949cae90c6e755d218d5cdca8f12 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 22 Sep 2019 19:49:03 +0200 Subject: vim-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 vim/vim#4927) https://github.com/vim/vim/commit/7a9bd7c1e0ce1baf5a02daf36eeae3638aa315c7 --- src/nvim/normal.c | 9 ++++++++- src/nvim/testdir/test_fold.vim | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index e7e6d2b365..ffdc8e23d7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6248,7 +6248,14 @@ static void nv_optrans(cmdarg_T *cap) if (cap->count0) { stuffnumReadbuff(cap->count0); } - stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); + // 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 *)"dd"); + } else { + stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); + } } cap->opcount = 0; } diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index 3cb42579be..03723b3cb5 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -756,3 +756,15 @@ func Test_fold_delete_with_marker() bwipe! bwipe! 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 -- cgit From 6c3d34e4dfc7fd3f810dd78f9dec016540c13bda Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 22 Sep 2019 20:04:34 +0200 Subject: vim-patch:8.1.2059: fix for "x" deleting a fold has side effects Problem: Fix for "x" deleting a fold has side effects. Solution: Fix it where the fold is included. https://github.com/vim/vim/commit/56ebbabea1d8409ba67127b9674f6c714739c8e0 --- src/nvim/normal.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ffdc8e23d7..4dfde96e94 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1553,9 +1553,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if (!VIsual_active) { if (hasFolding(oap->start.lnum, &oap->start.lnum, NULL)) oap->start.col = 0; - if (hasFolding(curwin->w_cursor.lnum, NULL, - &curwin->w_cursor.lnum)) + if ((curwin->w_cursor.col > 0 || oap->inclusive) + && hasFolding(curwin->w_cursor.lnum, NULL, + &curwin->w_cursor.lnum)) { curwin->w_cursor.col = (colnr_T)STRLEN(get_cursor_line_ptr()); + } } oap->end = curwin->w_cursor; curwin->w_cursor = oap->start; @@ -5125,14 +5127,10 @@ static void nv_right(cmdarg_T *cap) break; } else if (PAST_LINE) { curwin->w_set_curswant = true; - if (virtual_active()) + if (virtual_active()) { oneright(); - else { - if (has_mbyte) - curwin->w_cursor.col += - (*mb_ptr2len)(get_cursor_pos_ptr()); - else - ++curwin->w_cursor.col; + } else { + curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr()); } } } @@ -6248,14 +6246,7 @@ static void nv_optrans(cmdarg_T *cap) if (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 *)"dd"); - } else { - stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); - } + stuffReadbuff(ar[strchr(str, (char)cap->cmdchar) - str]); } cap->opcount = 0; } -- cgit