aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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