Re: Patch 8.0.1587

2018-03-13 Fir de Conversatie Elimar Riesebieter
* Bram Moolenaar  [2018-03-13 15:42 +0100]:

> 
> Christian wrote:
> 
> > On Do, 08 Mär 2018, Bram Moolenaar wrote:
> > 
> > > It is not.  "\" becomes a real Esc character, while in
> > > single quotes you get 6 characters.  We need the Esc character for this
> > > test.
> > 
> > I am seeing the same error, when running Vim in a session without access 
> > to the + clipboard. Perhaps we need to make sure, that accessing the 
> > clipboard "should" work:
> > 
> > diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
> > index 6450989ec..0f4ecc290 100644
> > --- a/src/testdir/test_paste.vim
> > +++ b/src/testdir/test_paste.vim
> > @@ -67,13 +67,13 @@ func Test_paste_insert_mode()
> >  endfunc
> > 
> >  func Test_paste_clipboard()
> > -  if !has('clipboard')
> > +  if !(has('clipboard') && (has("win32") || exists("$DISPLAY")))
> >  return
> >endif
> >let @+ = "nasty\:!ls\command"
> >new
> >exe "normal i\+\"
> > -  call assert_equal("nasty\:!ls\command", getline(1))
> > +  call assert_equal(["nasty\:!ls\command", ""], getline(1,2))
> >bwipe!
> >  endfunc
> 
> Let's make a function for that, we may need it in other places as well.
> 
> > The reason for the second change in the test is, that when pasting
> > literally does not work, Vim might insert
> > ,
> > | nasty
> > | mmandc
> > `
> > 
> > However, don't know, why the '+' register works differently, when
> > there is no access to the clipboard.
> 
> Hmm, there might not be a second line if the test passes.

Thanks Bram and Christian for fixing my issue in 8.0.1604 :-)

Elimar
-- 
  Learned men are the cisterns of knowledge,
  not the fountainheads ;-)

-- 
-- 
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: Patch 8.0.1587

2018-03-13 Fir de Conversatie Bram Moolenaar

Christian wrote:

> On Do, 08 Mär 2018, Bram Moolenaar wrote:
> 
> > It is not.  "\" becomes a real Esc character, while in
> > single quotes you get 6 characters.  We need the Esc character for this
> > test.
> 
> I am seeing the same error, when running Vim in a session without access 
> to the + clipboard. Perhaps we need to make sure, that accessing the 
> clipboard "should" work:
> 
> diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
> index 6450989ec..0f4ecc290 100644
> --- a/src/testdir/test_paste.vim
> +++ b/src/testdir/test_paste.vim
> @@ -67,13 +67,13 @@ func Test_paste_insert_mode()
>  endfunc
> 
>  func Test_paste_clipboard()
> -  if !has('clipboard')
> +  if !(has('clipboard') && (has("win32") || exists("$DISPLAY")))
>  return
>endif
>let @+ = "nasty\:!ls\command"
>new
>exe "normal i\+\"
> -  call assert_equal("nasty\:!ls\command", getline(1))
> +  call assert_equal(["nasty\:!ls\command", ""], getline(1,2))
>bwipe!
>  endfunc

Let's make a function for that, we may need it in other places as well.

> The reason for the second change in the test is, that when pasting
> literally does not work, Vim might insert
> ,
> | nasty
> | mmandc
> `
> 
> However, don't know, why the '+' register works differently, when
> there is no access to the clipboard.

Hmm, there might not be a second line if the test passes.

-- 
hundred-and-one symptoms of being an internet addict:
3. Your bookmark takes 15 minutes to scroll from top to bottom.

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


Re: Patch 8.0.1587

2018-03-12 Fir de Conversatie Christian Brabandt

On Do, 08 Mär 2018, Bram Moolenaar wrote:

> It is not.  "\" becomes a real Esc character, while in
> single quotes you get 6 characters.  We need the Esc character for this
> test.

I am seeing the same error, when running Vim in a session without access 
to the + clipboard. Perhaps we need to make sure, that accessing the 
clipboard "should" work:

diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
index 6450989ec..0f4ecc290 100644
--- a/src/testdir/test_paste.vim
+++ b/src/testdir/test_paste.vim
@@ -67,13 +67,13 @@ func Test_paste_insert_mode()
 endfunc

 func Test_paste_clipboard()
-  if !has('clipboard')
+  if !(has('clipboard') && (has("win32") || exists("$DISPLAY")))
 return
   endif
   let @+ = "nasty\:!ls\command"
   new
   exe "normal i\+\"
-  call assert_equal("nasty\:!ls\command", getline(1))
+  call assert_equal(["nasty\:!ls\command", ""], getline(1,2))
   bwipe!
 endfunc

The reason for the second change in the test is, that when pasting literally 
does not work,
Vim might insert
,
| nasty
| mmandc
`

However, don't know, why the '+' register works differently, when there is no 
access to the clipboard.

Best,
Christian
-- 
Der Eitelkeit oder ihrem Scheine entgeht niemand, wenn ihn nicht eine
große Idee erfüllt, die ihn gegen sein Selbst verblendet.
-- Jean Paul

-- 
-- 
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: Patch 8.0.1587

2018-03-08 Fir de Conversatie Bram Moolenaar

Elimar Riesebieter wrote:

> > > * Bram Moolenaar  [2018-03-06 19:51 +0100]:
> > > 
> > > > 
> > > > Patch 8.0.1587
> > > > Problem:inserting from the clipboard doesn't work literally
> > > > Solution:   When pasting from the * or + register always assume 
> > > > literally.
> > > > Files:  src/ops.c, src/proto/ops.pro, src/edit.c, src/ops.c,
> > > > src/testdir/test_paste.vim
> > > > 
> > > > 
> > > [...]
> > > > ***
> > > > *** 66,71 
> > > > --- 66,82 
> > > > bwipe!
> > > >   endfunc
> > > >   
> > > > + func Test_paste_clipboard()
> > > > +   if !has('clipboard')
> > > > + return
> > > > +   endif
> > > > +   let @+ = "nasty\:!ls\command"
> > > > +   new
> > > > +   exe "normal i\+\"
> > > > +   call assert_equal("nasty\:!ls\command", getline(1))
> > > > +   bwipe!
> > > > + endfunc
> > > > + 
> > > >   func Test_paste_cmdline()
> > > > call feedkeys(":a\[200~foo\bar\[201~b\\"\", 
> > > > 'xt')
> > > > call assert_equal("\"afoo\barb", getreg(':'))
> > > 
> > > Building gtk version on TERM=tmux-256color I get:
> > > 
> > > From test_paste.vim:
> > > Found errors in Test_paste_clipboard():
> > > function RunTheTest[38]..Test_paste_clipboard line 7: Expected 
> > > 'nasty\e:!ls\rcommand' but got 'nasty'
> > > TEST FAILURE
> > 
> > Strange.  It works fine for me, and Travis also passes.
> > Why would it fail for you?
> 
> Using single quotes instead of double quotes succeeded the test. I
> am building in $SHADOWDIR's and not sure whether the attached patch is
> correct, though

It is not.  "\" becomes a real Esc character, while in
single quotes you get 6 characters.  We need the Esc character for this
test.


-- 
I once paid $12 to peer at the box that held King Tutankhamen's little
bandage-covered midget corpse at the De Young Museum in San Francisco.  I
remember thinking how pleased he'd be about the way things turned out in his
afterlife.
(Scott Adams - The Dilbert principle)

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


Re: Patch 8.0.1587

2018-03-07 Fir de Conversatie Elimar Riesebieter
* Bram Moolenaar  [2018-03-07 22:09 +0100]:

> 
> Elimar Riesebieter wrote:
> 
> > * Bram Moolenaar  [2018-03-06 19:51 +0100]:
> > 
> > > 
> > > Patch 8.0.1587
> > > Problem:inserting from the clipboard doesn't work literally
> > > Solution:   When pasting from the * or + register always assume literally.
> > > Files:  src/ops.c, src/proto/ops.pro, src/edit.c, src/ops.c,
> > > src/testdir/test_paste.vim
> > > 
> > > 
> > [...]
> > > ***
> > > *** 66,71 
> > > --- 66,82 
> > > bwipe!
> > >   endfunc
> > >   
> > > + func Test_paste_clipboard()
> > > +   if !has('clipboard')
> > > + return
> > > +   endif
> > > +   let @+ = "nasty\:!ls\command"
> > > +   new
> > > +   exe "normal i\+\"
> > > +   call assert_equal("nasty\:!ls\command", getline(1))
> > > +   bwipe!
> > > + endfunc
> > > + 
> > >   func Test_paste_cmdline()
> > > call feedkeys(":a\[200~foo\bar\[201~b\\"\", 
> > > 'xt')
> > > call assert_equal("\"afoo\barb", getreg(':'))
> > 
> > Building gtk version on TERM=tmux-256color I get:
> > 
> > From test_paste.vim:
> > Found errors in Test_paste_clipboard():
> > function RunTheTest[38]..Test_paste_clipboard line 7: Expected 
> > 'nasty\e:!ls\rcommand' but got 'nasty'
> > TEST FAILURE
> 
> Strange.  It works fine for me, and Travis also passes.
> Why would it fail for you?

Using single quotes instead of double quotes succeeded the test. I
am building in $SHADOWDIR's and not sure whether the attached patch is
correct, though


>From 556dfb84dfda8b2a48d55583905ba7351cfb75b1 Mon Sep 17 00:00:00 2001
From: Elimar Riesebieter 
Date: Wed, 7 Mar 2018 23:56:02 +0100
Subject: [PATCH] Use single quotes in test_paste.vim

---
 src/testdir/test_paste.vim | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/testdir/test_paste.vim b/src/testdir/test_paste.vim
index 6450989ec..e846fa62f 100644
--- a/src/testdir/test_paste.vim
+++ b/src/testdir/test_paste.vim
@@ -70,10 +70,10 @@ func Test_paste_clipboard()
   if !has('clipboard')
 return
   endif
-  let @+ = "nasty\:!ls\command"
+  let @+ = 'nasty\:!ls\command'
   new
   exe "normal i\+\"
-  call assert_equal("nasty\:!ls\command", getline(1))
+  call assert_equal('nasty\:!ls\command', getline(1))
   bwipe!
 endfunc
 
-- 
2.16.2

Thanks
Elimar
-- 
  On the keyboard of life you have always
  to keep a finger at the escape key;-)

-- 
-- 
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: Patch 8.0.1587

2018-03-07 Fir de Conversatie Bram Moolenaar

Elimar Riesebieter wrote:

> * Bram Moolenaar  [2018-03-06 19:51 +0100]:
> 
> > 
> > Patch 8.0.1587
> > Problem:inserting from the clipboard doesn't work literally
> > Solution:   When pasting from the * or + register always assume literally.
> > Files:  src/ops.c, src/proto/ops.pro, src/edit.c, src/ops.c,
> > src/testdir/test_paste.vim
> > 
> > 
> [...]
> > ***
> > *** 66,71 
> > --- 66,82 
> > bwipe!
> >   endfunc
> >   
> > + func Test_paste_clipboard()
> > +   if !has('clipboard')
> > + return
> > +   endif
> > +   let @+ = "nasty\:!ls\command"
> > +   new
> > +   exe "normal i\+\"
> > +   call assert_equal("nasty\:!ls\command", getline(1))
> > +   bwipe!
> > + endfunc
> > + 
> >   func Test_paste_cmdline()
> > call feedkeys(":a\[200~foo\bar\[201~b\\"\", 
> > 'xt')
> > call assert_equal("\"afoo\barb", getreg(':'))
> 
> Building gtk version on TERM=tmux-256color I get:
> 
> From test_paste.vim:
> Found errors in Test_paste_clipboard():
> function RunTheTest[38]..Test_paste_clipboard line 7: Expected 
> 'nasty\e:!ls\rcommand' but got 'nasty'
> TEST FAILURE

Strange.  It works fine for me, and Travis also passes.
Why would it fail for you?

-- 
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS.  WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM!  IT REALLY WORKS!

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


Re: Patch 8.0.1587

2018-03-07 Fir de Conversatie Elimar Riesebieter
* Bram Moolenaar  [2018-03-06 19:51 +0100]:

> 
> Patch 8.0.1587
> Problem:inserting from the clipboard doesn't work literally
> Solution:   When pasting from the * or + register always assume literally.
> Files:  src/ops.c, src/proto/ops.pro, src/edit.c, src/ops.c,
> src/testdir/test_paste.vim
> 
> 
[...]
> ***
> *** 66,71 
> --- 66,82 
> bwipe!
>   endfunc
>   
> + func Test_paste_clipboard()
> +   if !has('clipboard')
> + return
> +   endif
> +   let @+ = "nasty\:!ls\command"
> +   new
> +   exe "normal i\+\"
> +   call assert_equal("nasty\:!ls\command", getline(1))
> +   bwipe!
> + endfunc
> + 
>   func Test_paste_cmdline()
> call feedkeys(":a\[200~foo\bar\[201~b\\"\", 'xt')
> call assert_equal("\"afoo\barb", getreg(':'))

Building gtk version on TERM=tmux-256color I get:

>From test_paste.vim:
Found errors in Test_paste_clipboard():
function RunTheTest[38]..Test_paste_clipboard line 7: Expected 
'nasty\e:!ls\rcommand' but got 'nasty'
TEST FAILURE

Elimar
-- 
  You cannot propel yourself forward by
  patting yourself on the back.

-- 
-- 
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.


Patch 8.0.1587

2018-03-06 Fir de Conversatie Bram Moolenaar

Patch 8.0.1587
Problem:inserting from the clipboard doesn't work literally
Solution:   When pasting from the * or + register always assume literally.
Files:  src/ops.c, src/proto/ops.pro, src/edit.c, src/ops.c,
src/testdir/test_paste.vim


*** ../vim-8.0.1586/src/ops.c   2018-03-04 18:07:04.268592346 +0100
--- src/ops.c   2018-03-06 19:49:23.179191594 +0100
***
*** 899,915 
   *
   * If regname is 0 and writing, use register 0
   * If regname is 0 and reading, use previous register
   */
! void
  get_yank_register(int regname, int writing)
  {
  int   i;
  
  y_append = FALSE;
  if ((regname == 0 || regname == '"') && !writing && y_previous != NULL)
  {
y_current = y_previous;
!   return;
  }
  i = regname;
  if (VIM_ISDIGIT(i))
--- 899,919 
   *
   * If regname is 0 and writing, use register 0
   * If regname is 0 and reading, use previous register
+  *
+  * Return TRUE when the register should be inserted literally (selection or
+  * clipboard).
   */
! int
  get_yank_register(int regname, int writing)
  {
  int   i;
+ int   ret = FALSE;
  
  y_append = FALSE;
  if ((regname == 0 || regname == '"') && !writing && y_previous != NULL)
  {
y_current = y_previous;
!   return ret;
  }
  i = regname;
  if (VIM_ISDIGIT(i))
***
*** 926,935 
--- 930,945 
  #ifdef FEAT_CLIPBOARD
  /* When selection is not available, use register 0 instead of '*' */
  else if (clip_star.available && regname == '*')
+ {
i = STAR_REGISTER;
+   ret = TRUE;
+ }
  /* When clipboard is not available, use register 0 instead of '+' */
  else if (clip_plus.available && regname == '+')
+ {
i = PLUS_REGISTER;
+   ret = TRUE;
+ }
  #endif
  #ifdef FEAT_DND
  else if (!writing && regname == '~')
***
*** 940,945 
--- 950,956 
  y_current = &(y_regs[i]);
  if (writing)  /* remember the register we write into for do_put() */
y_previous = y_current;
+ return ret;
  }
  
  #if defined(FEAT_CLIPBOARD) || defined(PROTO)
***
*** 1387,1398 
  int
  insert_reg(
  int   regname,
! int   literally)  /* insert literally, not as if typed */
  {
  long  i;
  int   retval = OK;
  char_u*arg;
  int   allocated;
  
  /*
   * It is possible to get into an endless loop by having CTRL-R a in
--- 1398,1410 
  int
  insert_reg(
  int   regname,
! int   literally_arg)  /* insert literally, not as if typed */
  {
  long  i;
  int   retval = OK;
  char_u*arg;
  int   allocated;
+ int   literally = literally_arg;
  
  /*
   * It is possible to get into an endless loop by having CTRL-R a in
***
*** 1423,1429 
  }
  else  /* name or number register */
  {
!   get_yank_register(regname, FALSE);
if (y_current->y_array == NULL)
retval = FAIL;
else
--- 1435,1442 
  }
  else  /* name or number register */
  {
!   if (get_yank_register(regname, FALSE))
!   literally = TRUE;
if (y_current->y_array == NULL)
retval = FAIL;
else
***
*** 1580,1591 
  int
  cmdline_paste_reg(
  int regname,
! int literally,/* Insert text literally instead of "as typed" */
  int remcr)/* don't add CR characters */
  {
  long  i;
  
! get_yank_register(regname, FALSE);
  if (y_current->y_array == NULL)
return FAIL;
  
--- 1593,1606 
  int
  cmdline_paste_reg(
  int regname,
! int literally_arg,/* Insert text literally instead of "as typed" 
*/
  int remcr)/* don't add CR characters */
  {
  long  i;
+ int   literally = literally_arg;
  
! if (get_yank_register(regname, FALSE))
!   literally = TRUE;
  if (y_current->y_array == NULL)
return FAIL;
  
*** ../vim-8.0.1586/src/proto/ops.pro   2017-03-12 20:37:16.836943099 +0100
--- src/proto/ops.pro   2018-03-06 19:38:28.075289523 +0100
***
*** 11,17 
  char_u *get_expr_line(void);
  char_u *get_expr_line_src(void);
  int valid_yank_reg(int regname, int writing);
! void get_yank_register(int regname, int writing);
  int may_get_selection(int regname);
  void *get_register(int name, int copy);
  void put_register(int name, void *reg);
--- 11,17 
  char_u *get_expr_line(void);
  char_u *get_expr_line_src(void);
  int valid_yank_reg