mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #18598 from zeertzjq/vim-8.2.4968
vim-patch:8.2.{4121,4968,4969}: invalid memory access
This commit is contained in:
commit
6613f58ceb
@ -209,6 +209,10 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
|
|||||||
curwin->w_changelistidx = curbuf->b_changelistlen;
|
curwin->w_changelistidx = curbuf->b_changelistlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VIsual_active) {
|
||||||
|
check_visual_pos();
|
||||||
|
}
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
if (wp->w_buffer == curbuf) {
|
if (wp->w_buffer == curbuf) {
|
||||||
// Mark this window to be redrawn later.
|
// Mark this window to be redrawn later.
|
||||||
|
@ -399,6 +399,24 @@ void check_cursor(void)
|
|||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if VIsual position is valid, correct it if not.
|
||||||
|
/// Can be called when in Visual mode and a change has been made.
|
||||||
|
void check_visual_pos(void)
|
||||||
|
{
|
||||||
|
if (VIsual.lnum > curbuf->b_ml.ml_line_count) {
|
||||||
|
VIsual.lnum = curbuf->b_ml.ml_line_count;
|
||||||
|
VIsual.col = 0;
|
||||||
|
VIsual.coladd = 0;
|
||||||
|
} else {
|
||||||
|
int len = (int)STRLEN(ml_get(VIsual.lnum));
|
||||||
|
|
||||||
|
if (VIsual.col > len) {
|
||||||
|
VIsual.col = len;
|
||||||
|
VIsual.coladd = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Make sure curwin->w_cursor is not on the NUL at the end of the line.
|
/// Make sure curwin->w_cursor is not on the NUL at the end of the line.
|
||||||
/// Allow it when in Visual mode and 'selection' is not "old".
|
/// Allow it when in Visual mode and 'selection' is not "old".
|
||||||
void adjust_cursor_col(void)
|
void adjust_cursor_col(void)
|
||||||
|
@ -6770,13 +6770,8 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
|
|||||||
|
|
||||||
// <C-S-Right> may have started Visual mode, adjust the position for
|
// <C-S-Right> may have started Visual mode, adjust the position for
|
||||||
// deleted characters.
|
// deleted characters.
|
||||||
if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum) {
|
if (VIsual_active) {
|
||||||
int len = (int)STRLEN(get_cursor_line_ptr());
|
check_visual_pos();
|
||||||
|
|
||||||
if (VIsual.col > len) {
|
|
||||||
VIsual.col = len;
|
|
||||||
VIsual.coladd = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ static const char_u *skip_string(const char_u *p)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p[i] == '\'') { // check for trailing '
|
if (p[i - 1] != NUL && p[i] == '\'') { // check for trailing '
|
||||||
p += i;
|
p += i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5311,6 +5311,13 @@ func Test_cindent_case()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was reading past the end of the line
|
||||||
|
func Test_cindent_check_funcdecl()
|
||||||
|
new
|
||||||
|
sil norm o0('\0=L
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_cindent_scopedecls()
|
func Test_cindent_scopedecls()
|
||||||
new
|
new
|
||||||
setl cindent ts=4 sw=4
|
setl cindent ts=4 sw=4
|
||||||
|
@ -1249,11 +1249,23 @@ endfunc
|
|||||||
|
|
||||||
func Test_visual_block_append_invalid_char()
|
func Test_visual_block_append_invalid_char()
|
||||||
" this was going over the end of the line
|
" this was going over the end of the line
|
||||||
|
set isprint=@,161-255
|
||||||
new
|
new
|
||||||
call setline(1, [' let xxx', 'xxxxx', 'xxxxxxxxxxx'])
|
call setline(1, [' let xxx', 'xxxxx', 'xxxxxxxxxxx'])
|
||||||
exe "normal 0\<C-V>jjA-\<Esc>"
|
exe "normal 0\<C-V>jjA-\<Esc>"
|
||||||
call assert_equal([' - let xxx', 'xxxxx -', 'xxxxxxxx-xxx'], getline(1, 3))
|
call assert_equal([' - let xxx', 'xxxxx -', 'xxxxxxxx-xxx'], getline(1, 3))
|
||||||
bwipe!
|
bwipe!
|
||||||
|
set isprint&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_visual_block_with_substitute()
|
||||||
|
" this was reading beyond the end of the line
|
||||||
|
new
|
||||||
|
norm a0)
|
||||||
|
sil! norm O
|
||||||
|
s/)
|
||||||
|
sil! norm
|
||||||
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_visual_reselect_with_count()
|
func Test_visual_reselect_with_count()
|
||||||
|
Loading…
Reference in New Issue
Block a user