To: vim_dev@googlegroups.com Subject: Patch 8.2.3391 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3391 Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes #8817) Files: src/drawline.c *** ../vim-8.2.3390/src/drawline.c 2021-08-05 17:56:03.208718221 +0200 --- src/drawline.c 2021-08-30 22:12:32.645851577 +0200 *************** *** 1970,1986 **** if (wp->w_p_lbr && c0 == c && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr)) { ! int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0; ! char_u *p = ptr - (mb_off + 1); // TODO: is passing p for start of the line OK? n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol, NULL) - 1; // We have just drawn the showbreak value, no need to add ! // space for it again if (vcol == vcol_sbr) n_extra -= MB_CHARLEN(get_showbreak_value(wp)); if (c == TAB && n_extra + col > wp->w_width) # ifdef FEAT_VARTABS --- 1970,1991 ---- if (wp->w_p_lbr && c0 == c && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr)) { ! int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) ! : 0; ! char_u *p = ptr - (mb_off + 1); // TODO: is passing p for start of the line OK? n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol, NULL) - 1; // We have just drawn the showbreak value, no need to add ! // space for it again. if (vcol == vcol_sbr) + { n_extra -= MB_CHARLEN(get_showbreak_value(wp)); + if (n_extra < 0) + n_extra = 0; + } if (c == TAB && n_extra + col > wp->w_width) # ifdef FEAT_VARTABS *** ../vim-8.2.3390/src/version.c 2021-08-31 20:46:34.876123765 +0200 --- src/version.c 2021-08-31 20:57:07.922010233 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3391, /**/ -- If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be "meetings." /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///