aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorraichoo <raichoo@googlemail.com>2017-03-11 10:46:50 +0100
committerraichoo <raichoo@googlemail.com>2017-03-19 21:14:11 +0100
commitae828982ceb9dc4c5bde58a276e6e10df6f35051 (patch)
tree7a5825075836640489dd37614f2f27b6c917cf30 /src/nvim/buffer.c
parent4500b16f15510f6091ca98b78aa4ee13e1acf2c7 (diff)
downloadrneovim-ae828982ceb9dc4c5bde58a276e6e10df6f35051.tar.gz
rneovim-ae828982ceb9dc4c5bde58a276e6e10df6f35051.tar.bz2
rneovim-ae828982ceb9dc4c5bde58a276e6e10df6f35051.zip
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. https://github.com/vim/vim/commit/c4a908e83690844b0d3a46124ba6af7d23485d69
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index f52989c74d..0a95cc9020 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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
* windows, so that autocommands in buf_freeall() don't get confused. */
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_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.
* The last (listed) buffer cannot be unloaded.