mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0962
closes #6726
Problem: Crash with virtualedit and joining lines.
(Joshua T Corbin, Neovim #6726)
Solution: When using a mark check that coladd is valid.
9aa1569128
This commit is contained in:
parent
6338199b76
commit
82b8382abe
@ -375,17 +375,27 @@ void check_cursor_col_win(win_T *win)
|
|||||||
win->w_cursor.col = 0;
|
win->w_cursor.col = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If virtual editing is on, we can leave the cursor on the old position,
|
// If virtual editing is on, we can leave the cursor on the old position,
|
||||||
* only we must set it to virtual. But don't do it when at the end of the
|
// only we must set it to virtual. But don't do it when at the end of the
|
||||||
* line. */
|
// line.
|
||||||
if (oldcol == MAXCOL)
|
if (oldcol == MAXCOL) {
|
||||||
win->w_cursor.coladd = 0;
|
win->w_cursor.coladd = 0;
|
||||||
else if (ve_flags == VE_ALL) {
|
} else if (ve_flags == VE_ALL) {
|
||||||
if (oldcoladd > win->w_cursor.col)
|
if (oldcoladd > win->w_cursor.col) {
|
||||||
win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
|
win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
|
||||||
else
|
if (win->w_cursor.col < len && win->w_cursor.coladd > 0) {
|
||||||
/* avoid weird number when there is a miscalculation or overflow */
|
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;
|
win->w_cursor.coladd = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1548,8 +1548,10 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
}
|
}
|
||||||
|
|
||||||
oap->start = VIsual;
|
oap->start = VIsual;
|
||||||
if (VIsual_mode == 'V')
|
if (VIsual_mode == 'V') {
|
||||||
oap->start.col = 0;
|
oap->start.col = 0;
|
||||||
|
oap->start.coladd = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6260,15 +6262,18 @@ static void nv_gomark(cmdarg_T *cap)
|
|||||||
} else
|
} else
|
||||||
nv_cursormark(cap, cap->arg, pos);
|
nv_cursormark(cap, cap->arg, pos);
|
||||||
|
|
||||||
/* May need to clear the coladd that a mark includes. */
|
// May need to clear the coladd that a mark includes.
|
||||||
if (!virtual_active())
|
if (!virtual_active()) {
|
||||||
curwin->w_cursor.coladd = 0;
|
curwin->w_cursor.coladd = 0;
|
||||||
|
}
|
||||||
|
check_cursor_col();
|
||||||
if (cap->oap->op_type == OP_NOP
|
if (cap->oap->op_type == OP_NOP
|
||||||
&& pos != NULL
|
&& pos != NULL
|
||||||
&& (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos))
|
&& (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos))
|
||||||
&& (fdo_flags & FDO_MARK)
|
&& (fdo_flags & FDO_MARK)
|
||||||
&& old_KeyTyped)
|
&& old_KeyTyped) {
|
||||||
foldOpenCursor();
|
foldOpenCursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -34,4 +34,5 @@ source test_taglist.vim
|
|||||||
source test_true_false.vim
|
source test_true_false.vim
|
||||||
source test_unlet.vim
|
source test_unlet.vim
|
||||||
source test_utf8.vim
|
source test_utf8.vim
|
||||||
|
source test_virtualedit.vim
|
||||||
source test_window_cmd.vim
|
source test_window_cmd.vim
|
||||||
|
31
src/nvim/testdir/test_virtualedit.vim
Normal file
31
src/nvim/testdir/test_virtualedit.vim
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user