Permalink
Browse files

patch 8.0.0962: crash with virtualedit and joining lines

Problem:    Crash with virtualedit and joining lines. (Joshua T Corbin, Neovim
            #6726)
Solution:   When using a mark check that coladd is valid.
  • Loading branch information...
brammool committed Aug 19, 2017
1 parent 98ebd2b commit 9aa156912867c05e0a6480925afe11c590378f09
Showing with 52 additions and 0 deletions.
  1. +1 −0 src/Makefile
  2. +11 −0 src/misc2.c
  3. +6 −0 src/normal.c
  4. +1 −0 src/testdir/test_alot.vim
  5. +31 −0 src/testdir/test_virtualedit.vim
  6. +2 −0 src/version.c
View
@@ -2274,6 +2274,7 @@ test_arglist \
test_utf8_comparisons \
test_viminfo \
test_vimscript \
test_virtualedit \
test_visual \
test_window_cmd \
test_window_id \
View
@@ -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;
View
@@ -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
@@ -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
@@ -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
View
@@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
962,
/**/
961,
/**/

3 comments on commit 9aa1569

@zdm

This comment has been minimized.

Show comment
Hide comment
@zdm

zdm Aug 23, 2017

Hello.
This commit brings issue with copy/paste under windows.
When I paste text in insert mode - it shift cursor position to 1 character to the left.

zdm replied Aug 23, 2017

Hello.
This commit brings issue with copy/paste under windows.
When I paste text in insert mode - it shift cursor position to 1 character to the left.

@brammool

This comment has been minimized.

Show comment
Hide comment
@brammool

brammool Aug 23, 2017

Contributor
Contributor

brammool replied Aug 23, 2017

@zdm

This comment has been minimized.

Show comment
Hide comment
@zdm

zdm Aug 24, 2017

copy something to clipboard and, then paste.
seems, that this is only windows bug.

for example, enter string 12345, and copy it.
than, paste it on next line (go to insert mode and press CTRL+V), cursor should be after "5" but he is before.

zdm replied Aug 24, 2017

copy something to clipboard and, then paste.
seems, that this is only windows bug.

for example, enter string 12345, and copy it.
than, paste it on next line (go to insert mode and press CTRL+V), cursor should be after "5" but he is before.

Please sign in to comment.