Re: Patch 8.1.1737

2019-07-25 Fir de Conversatie Bram Moolenaar


> On Tuesday, July 23, 2019 at 11:00:32 PM UTC+2, Bram Moolenaar wrote:
> > Patch 8.1.1737
> > Problem::args command that outputs one line gives more prompt.
> > Solution:   Only output line break if needed. (Daniel Hahler, closes #4715)
> > Files:  src/version.c, src/testdir/test_arglist.vim
> > 
> > 
> 
> This change introduced a bug. Start executing the following (after starting 
> "vim --clean"):
> 
> :let width = &columns / 3 - 4
> :let farg = repeat('f', width)
> :let garg = repeat('g', width)
> :exe 'args a b c d e' farg garg
> :args
> 
> The arguments will be printed on 2 lines with the 2nd line too long so it'll 
> be wrapped:
> 
> [a]d  gg
> b  e  c  
> fff
> fff
> 
> The proper way to display the args (the way previous vim versions did) is to 
> print them on 3 lines:
> 
> [a]d  gg
> b  e
> c  ff
> 
> The problem lies in this part:
> 
> > -   else
> > -   {
> > -   if (msg_col > 0)
> > -   msg_putchar('\n');
> > -   }
> >   }
> >   }
> 
> I suppose this was axed to avoid sending a '\n' at the end of the last line. 
> But it skips '\n' even for the second to last line - after printing args "b" 
> and "e". Or even more often. (In fact any time when idx >= item_count.) So I 
> suggest introducing the "else" branch back, like in the following patch:
> 
> @@ -4438,6 +4438,12 @@ list_in_columns(char_u **items, int size, int current)
>   msg_putchar(' ');
>   }
>   }
> + else
> + {
> + if (msg_col > 0 && cur_row < nrow)
> + msg_putchar('\n');
> + ++cur_row;
> + }
>  }
>  }

Thanks.  I verified this fixes the problem.  Would be nice to have a
test, but I don't want to delay sending out the fix.

> This issue is related to other 2 topics - to the ones which toothpik
> mentioned with subjects "version display horked" and "script stopped
> working". In the latter, he mentioned:
> 
> > i still maintain the --version output is horked
> 
> After the fix, the number of columns with features will be uniform
> once again. It might even help to get rid of the hang. Though I am not
> sure I run vim in the same way as toothpik as this is depends on
> &columns.

-- 
DENNIS: Oh, very nice. King, eh!  I expect you've got a palace and fine
clothes and courtiers and plenty of food.  And how d'you get that?  By
exploiting the workers! By hanging on to outdated imperialist dogma
which perpetuates the social and economic differences in our society!
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@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///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201907251952.x6PJqwdX031022%40masaka.moolenaar.net.


Re: Patch 8.1.1737

2019-07-24 Fir de Conversatie Tom M
On Tuesday, July 23, 2019 at 11:00:32 PM UTC+2, Bram Moolenaar wrote:
> Patch 8.1.1737
> Problem::args command that outputs one line gives more prompt.
> Solution:   Only output line break if needed. (Daniel Hahler, closes #4715)
> Files:src/version.c, src/testdir/test_arglist.vim
> 
> 

This change introduced a bug. Start executing the following (after starting 
"vim --clean"):

:let width = &columns / 3 - 4
:let farg = repeat('f', width)
:let garg = repeat('g', width)
:exe 'args a b c d e' farg garg
:args

The arguments will be printed on 2 lines with the 2nd line too long so it'll be 
wrapped:

[a]d  gg
b  e  c  fff
fff

The proper way to display the args (the way previous vim versions did) is to 
print them on 3 lines:

[a]d  gg
b  e
c  ff

The problem lies in this part:

> - else
> - {
> - if (msg_col > 0)
> - msg_putchar('\n');
> - }
>   }
>   }

I suppose this was axed to avoid sending a '\n' at the end of the last line. 
But it skips '\n' even for the second to last line - after printing args "b" 
and "e". Or even more often. (In fact any time when idx >= item_count.) So I 
suggest introducing the "else" branch back, like in the following patch:

@@ -4438,6 +4438,12 @@ list_in_columns(char_u **items, int size, int current)
msg_putchar(' ');
}
}
+   else
+   {
+   if (msg_col > 0 && cur_row < nrow)
+   msg_putchar('\n');
+   ++cur_row;
+   }
 }
 }

This issue is related to other 2 topics - to the ones which toothpik mentioned 
with subjects "version display horked" and "script stopped working". In the 
latter, he mentioned:

> i still maintain the --version output is horked

After the fix, the number of columns with features will be uniform once again. 
It might even help to get rid of the hang. Though I am not sure I run vim in 
the same way as toothpik as this is depends on &columns.

Tom M

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/07c5a316-3bee-481a-8902-bd5dade00b9c%40googlegroups.com.


Patch 8.1.1737

2019-07-23 Fir de Conversatie Bram Moolenaar


Patch 8.1.1737
Problem::args command that outputs one line gives more prompt.
Solution:   Only output line break if needed. (Daniel Hahler, closes #4715)
Files:  src/version.c, src/testdir/test_arglist.vim


*** ../vim-8.1.1736/src/version.c   2019-07-23 22:15:21.311518857 +0200
--- src/version.c   2019-07-23 22:55:05.615818414 +0200
***
*** 4351,4356 
--- 4353,4359 
  int   i;
  int   ncol;
  int   nrow;
+ int   cur_row = 1;
  int   item_count = 0;
  int   width = 0;
  #ifdef FEAT_SYN_HL
***
*** 4381,4392 
return;
  }
  
! /* The rightmost column doesn't need a separator.
!  * Sacrifice it to fit in one more column if possible. */
  ncol = (int) (Columns + 1) / width;
  nrow = item_count / ncol + (item_count % ncol ? 1 : 0);
  
! /* 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;
--- 4384,4395 
return;
  }
  
! // The rightmost column doesn't need a separator.
! // Sacrifice it to fit in one more column if possible.
  ncol = (int) (Columns + 1) / width;
  nrow = item_count / ncol + (item_count % ncol ? 1 : 0);
  
! // "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;
***
*** 4407,4414 
msg_putchar(']');
if (last_col)
{
!   if (msg_col > 0)
msg_putchar('\n');
}
else
{
--- 4410,4418 
msg_putchar(']');
if (last_col)
{
!   if (msg_col > 0 && cur_row < nrow)
msg_putchar('\n');
+   ++cur_row;
}
else
{
***
*** 4416,4426 
msg_putchar(' ');
}
}
-   else
-   {
-   if (msg_col > 0)
-   msg_putchar('\n');
-   }
  }
  }
  
--- 4420,4425 
*** ../vim-8.1.1736/src/testdir/test_arglist.vim2018-12-28 
19:29:31.743633958 +0100
--- src/testdir/test_arglist.vim2019-07-23 22:52:04.144231816 +0200
***
*** 140,149 
  
call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers)
  
!   redir => result
!   args
!   redir END
!   call assert_equal('a   b   [c] d', trim(result))
  
.argd
call assert_equal(['a', 'b', 'd'], argv())
--- 140,146 
  
call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers)
  
!   call assert_equal("\na   b   [c] d   ", execute(':args'))
  
.argd
call assert_equal(['a', 'b', 'd'], argv())
*** ../vim-8.1.1736/src/version.c   2019-07-23 22:15:21.311518857 +0200
--- src/version.c   2019-07-23 22:55:05.615818414 +0200
***
*** 779,780 
--- 779,782 
  {   /* Add new patch number below this line */
+ /**/
+ 1737,
  /**/

-- 
Clothes make the man.  Naked people have little or no influence on society.
   -- Mark Twain (Samuel Clemens) (1835-1910)

 /// Bram Moolenaar -- b...@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///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201907232100.x6NL0OkY028194%40masaka.moolenaar.net.