Skip to content

Commit

Permalink
patch 8.1.1760: extra line break for wrapping output of :args
Browse files Browse the repository at this point in the history
Problem:    Extra line break for wrapping output of :args.
Solution:   Avoid the extra line break. (Daniel Hahler, closes #4737)
  • Loading branch information
brammool committed Jul 27, 2019
1 parent 14371ed commit 9800bfe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
19 changes: 19 additions & 0 deletions src/testdir/test_arglist.vim
Expand Up @@ -169,6 +169,25 @@ func Test_argument()

let &hidden = save_hidden

let save_columns = &columns
let &columns = 79
exe 'args ' .. join(range(1, 81))
call assert_equal(join([
\ '',
\ '[1] 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 ',
\ '2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 ',
\ '3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 ',
\ '4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 ',
\ '5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 ',
\ ], "\n"),
\ execute('args'))

" No trailing newline with one item per row.
let long_arg = repeat('X', 81)
exe 'args ' .. long_arg
call assert_equal("\n[".long_arg.']', execute('args'))
let &columns = save_columns

" Setting argument list should fail when the current buffer has unsaved
" changes
%argd
Expand Down
17 changes: 11 additions & 6 deletions src/version.c
Expand Up @@ -777,6 +777,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1760,
/**/
1759,
/**/
Expand Down Expand Up @@ -4418,11 +4420,11 @@ list_in_columns(char_u **items, int size, int current)

if (Columns < width)
{
/* Not enough screen columns - show one per line */
// Not enough screen columns - show one per line
for (i = 0; i < item_count; ++i)
{
version_msg_wrap(items[i], i == current);
if (msg_col > 0)
if (msg_col > 0 && i < item_count - 1)
msg_putchar('\n');
}
return;
Expand All @@ -4433,7 +4435,7 @@ list_in_columns(char_u **items, int size, int current)
ncol = (int) (Columns + 1) / width;
nrow = item_count / ncol + (item_count % ncol ? 1 : 0);

// "i" counts columns then rows. idx counts rows then columns.
// "i" counts columns then rows. "idx" counts rows then columns.
for (i = 0; !got_int && i < nrow * ncol; ++i)
{
int idx = (i / ncol) + (i % ncol) * nrow;
Expand Down Expand Up @@ -4467,9 +4469,12 @@ list_in_columns(char_u **items, int size, int current)
else
{
// this row is out of items, thus at the end of the row
if (msg_col > 0 && cur_row < nrow)
msg_putchar('\n');
++cur_row;
if (msg_col > 0)
{
if (cur_row < nrow)
msg_putchar('\n');
++cur_row;
}
}
}
}
Expand Down

0 comments on commit 9800bfe

Please sign in to comment.