Patch 8.1.2325

12 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 21, 2019, 7:33:32 AM11/21/19
to vim...@googlegroups.com

Patch 8.1.2325
Problem: Crash when using balloon with empty line.
Solution: Handle empty lines. (Markus Braun)
Files: src/popupmenu.c, src/testdir/test_popup.vim


*** ../vim-8.1.2324/src/popupmenu.c 2019-11-21 12:12:07.921993053 +0100
--- src/popupmenu.c 2019-11-21 13:19:20.029312180 +0100
***************
*** 1209,1250 ****
int cells;

item = ((balpart_T *)ga.ga_data) + item_idx;
! for (skip = 0; skip < item->bytelen; skip += thislen)
! {
! if (split_long_items && item->cells >= BALLOON_MIN_WIDTH)
{
! cells = item->indent * 2;
! for (p = item->start + skip; p < item->start + item->bytelen;
p += mb_ptr2len(p))
! if ((cells += ptr2cells(p)) > BALLOON_MIN_WIDTH)
! break;
! thislen = p - (item->start + skip);
! }
! else
! thislen = item->bytelen;

! // put indent at the start
! p = alloc(thislen + item->indent * 2 + 1);
! if (p == NULL)
! {
! for (line = 0; line <= height - 1; ++line)
! vim_free((*array)[line].pum_text);
! vim_free(*array);
! goto failed;
! }
! for (ind = 0; ind < item->indent * 2; ++ind)
! p[ind] = ' ';

! // exclude spaces at the end of the string
! for (copylen = thislen; copylen > 0; --copylen)
! if (item->start[skip + copylen - 1] != ' ')
! break;

! vim_strncpy(p + ind, item->start + skip, copylen);
! (*array)[line].pum_text = p;
! item->indent = 0; /* wrapped line has no indent */
! ++line;
! }
}
ga_clear(&ga);
return height;
--- 1209,1254 ----
int cells;

item = ((balpart_T *)ga.ga_data) + item_idx;
! if (item->bytelen == 0)
! (*array)[line++].pum_text = vim_strsave((char_u *)"");
! else
! for (skip = 0; skip < item->bytelen; skip += thislen)
{
! if (split_long_items && item->cells >= BALLOON_MIN_WIDTH)
! {
! cells = item->indent * 2;
! for (p = item->start + skip;
! p < item->start + item->bytelen;
p += mb_ptr2len(p))
! if ((cells += ptr2cells(p)) > BALLOON_MIN_WIDTH)
! break;
! thislen = p - (item->start + skip);
! }
! else
! thislen = item->bytelen;

! // put indent at the start
! p = alloc(thislen + item->indent * 2 + 1);
! if (p == NULL)
! {
! for (line = 0; line <= height - 1; ++line)
! vim_free((*array)[line].pum_text);
! vim_free(*array);
! goto failed;
! }
! for (ind = 0; ind < item->indent * 2; ++ind)
! p[ind] = ' ';

! // exclude spaces at the end of the string
! for (copylen = thislen; copylen > 0; --copylen)
! if (item->start[skip + copylen - 1] != ' ')
! break;

! vim_strncpy(p + ind, item->start + skip, copylen);
! (*array)[line].pum_text = p;
! item->indent = 0; /* wrapped line has no indent */
! ++line;
! }
}
ga_clear(&ga);
return height;
*** ../vim-8.1.2324/src/testdir/test_popup.vim 2019-08-23 22:31:33.217176868 +0200
--- src/testdir/test_popup.vim 2019-11-21 13:21:41.461007028 +0100
***************
*** 795,800 ****
--- 795,806 ----
\ ' next = 123}',
\ ], balloon_split(
\ 'struct = 0x234 {long = 2343 "\\"some long string that will be wrapped in two\\"", next = 123}'))
+ call assert_equal([
+ \ 'Some comment',
+ \ '',
+ \ 'typedef this that;',
+ \ ], balloon_split(
+ \ "Some comment\n\ntypedef this that;"))
endfunc

func Test_popup_position()
*** ../vim-8.1.2324/src/version.c 2019-11-21 12:12:07.921993053 +0100
--- src/version.c 2019-11-21 13:23:00.052837114 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2325,
/**/

--
hundred-and-one symptoms of being an internet addict:
95. Only communication in your household is through email.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages