Skip to content

Commit 02f8694

Browse files
committed
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 #8767)
1 parent ccfb7c6 commit 02f8694

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/misc2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ coladvance2(
161161
if (finetune
162162
&& curwin->w_p_wrap
163163
&& curwin->w_width != 0
164-
&& wcol >= (colnr_T)width)
164+
&& wcol >= (colnr_T)width
165+
&& width > 0)
165166
{
166167
csize = linetabsize(line);
167168
if (csize > 0)

src/testdir/test_number.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,15 @@ func Test_number_rightleft()
320320
bw!
321321
endfunc
322322

323+
" This used to cause a divide by zero
324+
func Test_number_no_text_virtual_edit()
325+
vnew
326+
call setline(1, ['line one', 'line two'])
327+
set number virtualedit=all
328+
normal w
329+
4wincmd |
330+
normal j
331+
bwipe!
332+
endfunc
333+
323334
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3357,
758760
/**/
759761
3356,
760762
/**/

0 commit comments

Comments
 (0)