aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-02 06:32:24 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-02 06:55:23 +0800
commit0b15c019124965920c5f2df8c8ee75cd46311d27 (patch)
treef5cc59bd63b62a8c8e8f205e3a15ff77033779d5
parent9b4d0137b89d5d2ed6c62549578868d7a68fb094 (diff)
downloadrneovim-0b15c019124965920c5f2df8c8ee75cd46311d27.tar.gz
rneovim-0b15c019124965920c5f2df8c8ee75cd46311d27.tar.bz2
rneovim-0b15c019124965920c5f2df8c8ee75cd46311d27.zip
vim-patch:9.0.0017: accessing memory beyond the end of the line
Problem: Accessing memory beyond the end of the line. Solution: Stop Visual mode when closing a window. https://github.com/vim/vim/commit/3d51ce18ab1be4f9f6061568a4e7fabf00b21794
-rw-r--r--src/nvim/testdir/test_visual.vim12
-rw-r--r--src/nvim/window.c2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim
index 41c29c5bb0..492750fa66 100644
--- a/src/nvim/testdir/test_visual.vim
+++ b/src/nvim/testdir/test_visual.vim
@@ -1431,5 +1431,17 @@ func Test_visual_paste_clipboard()
bwipe!
endfunc
+func Test_visual_area_adjusted_when_hiding()
+ " The Visual area ended after the end of the line after :hide
+ call setline(1, 'xxx')
+ vsplit Xfile
+ call setline(1, 'xxxxxxxx')
+ norm! $o
+ hid
+ norm! zW
+ bwipe!
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 9ac027d80f..38597b8b77 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -2741,6 +2741,8 @@ int win_close(win_T *win, bool free_buf, bool force)
* to be the last one left, return now.
*/
if (wp->w_buffer != curbuf) {
+ reset_VIsual_and_resel(); // stop Visual mode
+
other_buffer = true;
win->w_closing = true;
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, false, curbuf);