diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-08-19 15:05:32 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-08-19 15:05:32 +0200 |
commit | 9aa156912867c05e0a6480925afe11c590378f09 (patch) | |
tree | 8edcc2a13208a239bf234c32f6dde2e6fc0ad01e /src | |
parent | 98ebd2bbec3443878dd0ed772ab67efb618f2fad (diff) | |
download | vim-git-9aa156912867c05e0a6480925afe11c590378f09.tar.gz |
patch 8.0.0962: crash with virtualedit and joining linesv8.0.0962
Problem: Crash with virtualedit and joining lines. (Joshua T Corbin, Neovim
#6726)
Solution: When using a mark check that coladd is valid.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 1 | ||||
-rw-r--r-- | src/misc2.c | 11 | ||||
-rw-r--r-- | src/normal.c | 6 | ||||
-rw-r--r-- | src/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_virtualedit.vim | 31 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 52 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile index de4b24064..1f252f056 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2274,6 +2274,7 @@ test_arglist \ test_utf8_comparisons \ test_viminfo \ test_vimscript \ + test_virtualedit \ test_visual \ test_window_cmd \ test_window_id \ diff --git a/src/misc2.c b/src/misc2.c index 541069e54..17fa424bc 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -605,7 +605,18 @@ check_cursor_col_win(win_T *win) else if (ve_flags == VE_ALL) { if (oldcoladd > win->w_cursor.col) + { win->w_cursor.coladd = oldcoladd - win->w_cursor.col; + if (win->w_cursor.col < len && win->w_cursor.coladd > 0) + { + int cs, ce; + + /* check that coladd is not more than the char width */ + getvcol(win, &win->w_cursor, &cs, NULL, &ce); + if (win->w_cursor.coladd > ce - cs) + win->w_cursor.coladd = ce - cs; + } + } else /* avoid weird number when there is a miscalculation or overflow */ win->w_cursor.coladd = 0; diff --git a/src/normal.c b/src/normal.c index c543635ef..f08f52f9f 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1571,7 +1571,12 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) oap->start = VIsual; if (VIsual_mode == 'V') + { oap->start.col = 0; +# ifdef FEAT_VIRTUALEDIT + oap->start.coladd = 0; +# endif + } } /* @@ -7580,6 +7585,7 @@ nv_gomark(cmdarg_T *cap) if (!virtual_active()) curwin->w_cursor.coladd = 0; #endif + check_cursor_col(); #ifdef FEAT_FOLDING if (cap->oap->op_type == OP_NOP && pos != NULL diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 8e245ed20..e83256a4d 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -55,4 +55,5 @@ source test_taglist.vim source test_timers.vim source test_true_false.vim source test_unlet.vim +source test_virtualedit.vim source test_window_cmd.vim diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim new file mode 100644 index 000000000..da143c518 --- /dev/null +++ b/src/testdir/test_virtualedit.vim @@ -0,0 +1,31 @@ +" Tests for 'virtualedit'. + +func Test_yank_move_change() + split + call setline(1, [ + \ "func foo() error {", + \ "\tif n, err := bar();", + \ "\terr != nil {", + \ "\t\treturn err", + \ "\t}", + \ "\tn = n * n", + \ ]) + set virtualedit=all + set ts=4 + function! MoveSelectionDown(count) abort + normal! m` + silent! exe "'<,'>move'>+".a:count + norm! `` + endfunction + + xmap ]e :<C-U>call MoveSelectionDown(v:count1)<CR> + 2 + normal 2gg + normal J + normal jVj + normal ]e + normal ce + bwipe! + set virtualedit= + set ts=8 +endfunc diff --git a/src/version.c b/src/version.c index a25bbadcb..1ba0073b0 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 962, +/**/ 961, /**/ 960, |