mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
vim-patch:7.4.2347
Problem: Crash when closing a buffer while Visual mode is active.
(Dominique Pelle)
Solution: Adjust the position before computing the number of lines.
When closing the current buffer stop Visual mode.
c4a908e836
This commit is contained in:
@@ -438,6 +438,13 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
|
|||||||
/* Remember if we are closing the current buffer. Restore the number of
|
/* Remember if we are closing the current buffer. Restore the number of
|
||||||
* windows, so that autocommands in buf_freeall() don't get confused. */
|
* windows, so that autocommands in buf_freeall() don't get confused. */
|
||||||
bool is_curbuf = (buf == curbuf);
|
bool is_curbuf = (buf == curbuf);
|
||||||
|
|
||||||
|
// When closing the current buffer stop Visual mode before freeing
|
||||||
|
// anything.
|
||||||
|
if (is_curbuf) {
|
||||||
|
end_visual_mode();
|
||||||
|
}
|
||||||
|
|
||||||
buf->b_nwindows = nwindows;
|
buf->b_nwindows = nwindows;
|
||||||
|
|
||||||
buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
|
buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
|
||||||
@@ -1075,6 +1082,11 @@ do_buffer (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When closing the current buffer stop Visual mode.
|
||||||
|
if (buf == curbuf) {
|
||||||
|
end_visual_mode();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If deleting the last (listed) buffer, make it empty.
|
* If deleting the last (listed) buffer, make it empty.
|
||||||
* The last (listed) buffer cannot be unloaded.
|
* The last (listed) buffer cannot be unloaded.
|
||||||
|
@@ -1596,6 +1596,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
oap->start = curwin->w_cursor;
|
oap->start = curwin->w_cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Just in case lines were deleted that make the position invalid.
|
||||||
|
check_pos(curwin->w_buffer, &oap->end);
|
||||||
oap->line_count = oap->end.lnum - oap->start.lnum + 1;
|
oap->line_count = oap->end.lnum - oap->start.lnum + 1;
|
||||||
|
|
||||||
/* Set "virtual_op" before resetting VIsual_active. */
|
/* Set "virtual_op" before resetting VIsual_active. */
|
||||||
@@ -7831,7 +7833,6 @@ static void get_op_vcol(
|
|||||||
|
|
||||||
// prevent from moving onto a trail byte
|
// prevent from moving onto a trail byte
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
check_pos(curwin->w_buffer, &oap->end);
|
|
||||||
mb_adjustpos(curwin->w_buffer, &oap->end);
|
mb_adjustpos(curwin->w_buffer, &oap->end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1998,3 +1998,17 @@ func! Test_normal46_ignore()
|
|||||||
" clean up
|
" clean up
|
||||||
bw!
|
bw!
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
|
func! Test_normal47_visual_buf_wipe()
|
||||||
|
" This was causing a crash or ml_get error.
|
||||||
|
enew!
|
||||||
|
call setline(1,'xxx')
|
||||||
|
normal $
|
||||||
|
new
|
||||||
|
call setline(1, range(1,2))
|
||||||
|
2
|
||||||
|
exe "norm \<C-V>$"
|
||||||
|
bw!
|
||||||
|
norm yp
|
||||||
|
set nomodified
|
||||||
|
endfu
|
||||||
|
@@ -94,7 +94,7 @@ static int included_patches[] = {
|
|||||||
// 2350,
|
// 2350,
|
||||||
// 2349,
|
// 2349,
|
||||||
// 2348,
|
// 2348,
|
||||||
// 2347,
|
2347,
|
||||||
// 2346,
|
// 2346,
|
||||||
// 2345 NA
|
// 2345 NA
|
||||||
// 2344 NA
|
// 2344 NA
|
||||||
|
Reference in New Issue
Block a user