aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-08-21 16:13:51 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-09-17 02:10:44 +0100
commit26b7faf1f21c8583587df2e8ed9c3ac3426f677d (patch)
treecc42fd2f61fc9371247f256729cd201d279f4a46 /src
parent2ddfd6b9994d1d81b45f38e7e9a2e7ce0333c4e8 (diff)
downloadrneovim-26b7faf1f21c8583587df2e8ed9c3ac3426f677d.tar.gz
rneovim-26b7faf1f21c8583587df2e8ed9c3ac3426f677d.tar.bz2
rneovim-26b7faf1f21c8583587df2e8ed9c3ac3426f677d.zip
vim-patch:8.2.3357: crash when 'virtualedit' is set and window is narrow
Problem: Crash when 'virtualedit' is set and window is narrow. () Solution: Check that width is not zero. (closes vim/vim#8767) https://github.com/vim/vim/commit/02f8694a6bd116ab3316add4a7ea6735bf2e8839
Diffstat (limited to 'src')
-rw-r--r--src/nvim/cursor.c3
-rw-r--r--src/nvim/testdir/test_number.vim11
2 files changed, 13 insertions, 1 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index d4a68adeda..21f23b7fd4 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -130,7 +130,8 @@ static int coladvance2(
if (finetune
&& curwin->w_p_wrap
&& curwin->w_width_inner != 0
- && wcol >= (colnr_T)width) {
+ && wcol >= (colnr_T)width
+ && width > 0) {
csize = linetabsize(line);
if (csize > 0)
csize--;
diff --git a/src/nvim/testdir/test_number.vim b/src/nvim/testdir/test_number.vim
index 92a1bf3c9a..d737ebe9f0 100644
--- a/src/nvim/testdir/test_number.vim
+++ b/src/nvim/testdir/test_number.vim
@@ -320,4 +320,15 @@ func Test_number_rightleft()
bw!
endfunc
+" This used to cause a divide by zero
+func Test_number_no_text_virtual_edit()
+ vnew
+ call setline(1, ['line one', 'line two'])
+ set number virtualedit=all
+ normal w
+ 4wincmd |
+ normal j
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab