Patch 8.0.0543

2017-04-04 Fir de Conversatie Bram Moolenaar

Patch 8.0.0543
Problem:Test_edit causes older xfce4-terminal to close. (Dominique Pelle)
Solution:   Reduce number of columns to 2000.  Try to restore the window
position.
Files:  src/testdir/test_edit.vim, src/evalfunc.c, src/term.c,
src/proto/term.pro, src/term.h


*** ../vim-8.0.0542/src/testdir/test_edit.vim   2017-04-01 14:13:11.866693326 
+0200
--- src/testdir/test_edit.vim   2017-04-04 22:33:33.907147970 +0200
***
*** 1328,1337 
  " Long directory names only work on Unix.
  return
endif
let save_columns = 
!   set columns=5000
!   call assert_equal(5000, )
set noswapfile
let dirname = getcwd() . "/Xdir"
let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
let longfilename = longdirname . '/' . repeat('a', 255)
--- 1328,1341 
  " Long directory names only work on Unix.
  return
endif
+   " Try to get the Vim window position before setting 'columns'.
+   let winposx = getwinposx()
+   let winposy = getwinposy()
let save_columns = 
!   set columns=2000
!   call assert_equal(2000, )
set noswapfile
+ 
let dirname = getcwd() . "/Xdir"
let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
let longfilename = longdirname . '/' . repeat('a', 255)
***
*** 1345,1349 
--- 1349,1356 
exe 'bwipe! ' . longfilename
call delete(dirname, 'rf')
let  = save_columns
+   if winposx >= 0 && winposy >= 0
+ exe 'winpos ' . winposx . ' ' . winposy
+   endif
set swapfile&
  endfunc
*** ../vim-8.0.0542/src/evalfunc.c  2017-03-29 14:19:21.882199174 +0200
--- src/evalfunc.c  2017-04-04 21:50:59.879208445 +0200
***
*** 5242,5265 
  }
  
  /*
-  * "getwinposx()" function
-  */
- static void
- f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
- {
- rettv->vval.v_number = -1;
- #ifdef FEAT_GUI
- if (gui.in_use)
- {
-   int x, y;
- 
-   if (gui_mch_get_winpos(, ) == OK)
-   rettv->vval.v_number = x;
- }
- #endif
- }
- 
- /*
   * "win_findbuf()" function
   */
  static void
--- 5242,5247 
***
*** 5307,5312 
--- 5289,5320 
  }
  
  /*
+  * "getwinposx()" function
+  */
+ static void
+ f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+ rettv->vval.v_number = -1;
+ #ifdef FEAT_GUI
+ if (gui.in_use)
+ {
+   int x, y;
+ 
+   if (gui_mch_get_winpos(, ) == OK)
+   rettv->vval.v_number = x;
+ }
+ #endif
+ #if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+ {
+   int x, y;
+ 
+   if (term_get_winpos(, ) == OK)
+   rettv->vval.v_number = x;
+ }
+ #endif
+ }
+ 
+ /*
   * "getwinposy()" function
   */
  static void
***
*** 5322,5327 
--- 5330,5343 
rettv->vval.v_number = y;
  }
  #endif
+ #if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+ {
+   int x, y;
+ 
+   if (term_get_winpos(, ) == OK)
+   rettv->vval.v_number = y;
+ }
+ #endif
  }
  
  /*
*** ../vim-8.0.0542/src/term.c  2017-04-02 17:21:09.890069493 +0200
--- src/term.c  2017-04-04 22:33:20.819229358 +0200
***
*** 845,853 
--- 845,855 
  ESC_STR "[8;%p1%d;%p2%dt")},
  {(int)KS_CWP, IF_EB("\033[3;%p1%d;%p2%dt",
  ESC_STR "[3;%p1%d;%p2%dt")},
+ {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")},
  #  else
  {(int)KS_CWS, IF_EB("\033[8;%d;%dt", ESC_STR "[8;%d;%dt")},
  {(int)KS_CWP, IF_EB("\033[3;%d;%dt", ESC_STR "[3;%d;%dt")},
+ {(int)KS_CGP, IF_EB("\033[13t", ESC_STR "[13t")},
  #  endif
  {(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")},
  {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")},
***
*** 2581,2586 
--- 2583,2642 
  OUT_STR(tgoto((char *)T_CWP, y, x));
  }
  
+ # if defined(FEAT_TERMRESPONSE) || defined(PROTO)
+ /*
+  * Return TRUE if we can request the terminal for a response.
+  */
+ static int
+ can_get_termresponse()
+ {
+ return cur_tmode == TMODE_RAW
+   && termcap_active
+ # ifdef UNIX
+   && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd)))
+ # endif
+   && p_ek;
+ }
+ 
+ static int winpos_x;
+ static int winpos_y;
+ static int waiting_for_winpos = FALSE;
+ 
+ /*
+  * Try getting the Vim window position from the terminal.
+  * Returns OK or FAIL.
+  */
+ int
+ term_get_winpos(int *x, int *y)
+ {
+ int count = 0;
+ 
+ if (*T_CGP == NUL || !can_get_termresponse())
+   return FAIL;
+ winpos_x = -1;
+ winpos_y = -1;
+ waiting_for_winpos = TRUE;
+ OUT_STR(T_CGP);
+ out_flush();
+ 
+ /* Try reading the result for 100 msec. */
+ while (count++ < 10)
+ {
+   (void)vpeekc_nomap();
+   if (winpos_x >= 0 && winpos_y >= 0)
+   {
+   *x = 

Re: [bug] Test_edit_complete_very_long_name() fails when running tests from xfce4-terminal

2017-04-04 Fir de Conversatie Bram Moolenaar

Dominique wrote:

> >> On Sun, Apr 2, 2017 at 9:28 PM, Dominique Pellé
> >>  wrote:
> >> > Hi
> >> >
> >> > Running "make test" with vim-8.0.540
> >> > on xubuntu-14.04 x86_64 stops during the
> >> > test and even closes all my terminal windows!?
> >> > It's rather strange and dangerous that all
> >> > terminals are closed.
> >> >
> >> > Same bug also happens on xubuntu-16.04 x86.
> >> > It happens all the time.
> >> >
> >> > Running a single test "cd vim; make test_edit" is
> >> > enough to reproduce the problem.
> >> >
> >> > The last file written in testdir is testdir/message
> >> > and the last lines in the file are:
> >> >
> >> > ...
> >> > Executing Test_edit_HOME_END()
> >> > Executing Test_edit_INS()
> >> > Executing Test_edit_LEFT_RIGHT()
> >> > Executing Test_edit_MOUSE()
> >> > Executing Test_edit_PAGEUP_PAGEDOWN()
> >> > Executing Test_edit_complete_very_long_name()
> >> > Executing Test_edit_forbidden()
> >> > Executing Test_edit_rightleft()
> >> > Executed 41 tests
> >> > 1 FAILED:
> >> > Found errors in Test_edit_complete_very_long_name():
> >> > Caught exception in Test_edit_complete_very_long_name(): Vim:Interrupt
> >> > @ function RunTheTest[24]..Test_edit_complete_very_long_name, line 16
> >> >
> >> >
> >> > The terminal is xfce4-terminal.  If I run
> >> > tests from a xterm terminal instead, then
> >> > the test pass.
> >> >
> >> > The bug also happens when running the test with valgrind in 
> >> > xfce4-terminal.
> >> > Valgrind log shows no error, but testdir/messages  has different 
> >> > information
> >> > when ran from valgrind:
> >> >
> >> > Executing Test_edit_complete_very_long_name()
> >> > Executing Test_edit_forbidden()
> >> > Executing Test_edit_rightleft()
> >> > Executed 41 tests
> >> > 1 FAILED:
> >> > Found errors in Test_edit_complete_very_long_name():
> >> > Caught exception in Test_edit_complete_very_long_name():
> >> > Vim(call):E739: Cannot create directory:
> >> > /home/pel/sb/vim/src/testdir/Xdir/ddd/ddd/ddd/d
 dd
> >> > @ function RunTheTest[24]..Test_edit_complete_very_long_name, line 12
> >
> > Strange that creating the directory depends on the terminal.  Perhaps
> > the file system is also different?
> >
> > We could catch the failure to create the directory and not fail the
> > test.  But I would like to know why it fails.
> >
> >
> >> > I'm not sure yet what's going on here. Any idea?
> >> >
> >> > Vim was configured with:
> >> >
> >> > $ CC=clang-4.0 ./configure --with-features=huge --enable-gui=none
> >> >
> >> > Regards
> >> > Dominique
> >>
> >>
> >> I found that the test passes if I change it as follows:
> >>
> >> diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
> >> index 4db7bcf..afc3163 100644
> >> --- a/src/testdir/test_edit.vim
> >> +++ b/src/testdir/test_edit.vim
> >> @@ -1329,8 +1329,8 @@ func Test_edit_complete_very_long_name()
> >>  return
> >>endif
> >>let save_columns = 
> >> -  set columns=5000
> >> -  call assert_equal(5000, )
> >> +  set columns=100
> >> +  call assert_equal(100, )
> >>set noswapfile
> >>let dirname = getcwd() . "/Xdir"
> >>let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
> >>
> >>
> >> Why does this test set 'columns' to a very large value?
> >> I don't understand it.
> >
> > The original bug was for not checking that the result of truncating the
> > file name, to fit in the command line area, would fit in IObuffer.
> > Since IObuffer is about 1024 bytes, the 'columns' value has to be much
> > more than that.  I suppose 1200 would also work to reproduce the bug.
> >
> >> I also found that the following command is
> >> enough to close all xfce4-terminal's when run
> >> it from a xfce4-terminal:
> >>
> >> $ vim -u NONE -c 'set columns=5000'
> >>
> >> It must be a bug in xfce4-terminal.
> >
> > That indeed sounds like a bug in that terminal.  Perhaps we can do
> > something like
> > if $TERM =~ 'xfce4-terminal'
> >   throw "Skipped: xfce4 can't cope with this test"
> > endif
> 
> My TERM 

Re: Inconsistency between the different insert mode * commands

2017-04-04 Fir de Conversatie Ramel Eshed
On Monday, April 3, 2017 at 10:36:06 PM UTC+3, Bram Moolenaar wrote:
> Ramel Eshed wrote:
> 
> > vim -u NONE
> > 
> > ia="b\n"
> > 
> > results:
> > ab
> > 
> > 
> > This should be the expected behavior as I understand. But if I use instead:
> > ia="b\n"
> > 
> > I get:
> > b
> > a
> > 
> > Also:
> > 
> > ia="b\n"
> > I get:
> > ab^@
> > 
> > -the ^@ is displayed instead of an empty new line.
> > 
> > I'm using vim 8.0.540 on RHEL6. Please look into it.
> 
> Vim offers those different commands to be able to insert different
> things.  So it's normal that they work differently.
> 
> On top of that, it appears that in the second case the register is
> recognized as linewise, since the text ends in a NL.
> 

Hi Bram,

I'm aware to the differences between these commands. According to the 
documentation both  and  insert the text literally and the 
only difference is if the formatting options are used or not. I don't see how 
formatting is related to my example or why one command uses a linewise register 
while the other is not.

Also, I'm not sure if this is related, but I noticed that the results of the 
following two sequences are different:
1) ia="b\n"
2) let @b="b\n"
   iab

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [vim/vim] Make menus available to scripts (#1563)

2017-04-04 Fir de Conversatie h_east
Hi,

2017-4-4(Tue) 14:12:36 UTC+9 Nikolai Aleksandrovich Pavlov:
> #1563 (comment) looks like my comment because Bram is quoting me, but this is 
> from Bram. Something is wrong with @vim-ml.

This is a bug of google groups that happens often before. maybe.
https://groups.google.com/d/topic/vim_dev/Ih7PQP8ssbc/discussion

It is not quite fixed...

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
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.
For more options, visit https://groups.google.com/d/optout.