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(int regname, int writing);
! int 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);
***************
*** 19,25 ****
int yank_register_mline(int regname);
int do_record(int c);
int do_execreg(int regname, int colon, int addcr, int silent);
! int insert_reg(int regname, int literally);
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
int cmdline_paste_reg(int regname, int literally, int remcr);
void adjust_clip_reg(int *rp);
--- 19,25 ----
int yank_register_mline(int regname);
int do_record(int c);
int do_execreg(int regname, int colon, int addcr, int silent);
! int insert_reg(int regname, int literally_arg);
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
int cmdline_paste_reg(int regname, int literally, int remcr);
void adjust_clip_reg(int *rp);
*** ../vim-8.0.1586/src/testdir/test_paste.vim 2017-02-04 21:34:27.293529871
+0100
--- src/testdir/test_paste.vim 2018-03-06 19:48:03.531689147 +0100
***************
*** 1,4 ****
! " Tests for bracketed paste.
" Bracketed paste only works with "xterm". Not in GUI.
if has('gui_running')
--- 1,4 ----
! " Tests for bracketed paste and other forms of pasting.
" Bracketed paste only works with "xterm". Not in GUI.
if has('gui_running')
***************
*** 66,71 ****
--- 66,82 ----
bwipe!
endfunc
+ func Test_paste_clipboard()
+ if !has('clipboard')
+ return
+ endif
+ let @+ = "nasty\<Esc>:!ls\<CR>command"
+ new
+ exe "normal i\<C-R>+\<Esc>"
+ call assert_equal("nasty\<Esc>:!ls\<CR>command", getline(1))
+ bwipe!
+ endfunc
+
func Test_paste_cmdline()
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
call assert_equal("\"afoo\<CR>barb", getreg(':'))
*** ../vim-8.0.1586/src/version.c 2018-03-06 18:59:53.493546055 +0100
--- src/version.c 2018-03-06 19:50:34.502746190 +0100
***************
*** 768,769 ****
--- 768,771 ----
{ /* Add new patch number below this line */
+ /**/
+ 1587,
/**/
--
BEDEVERE: And that, my lord, is how we know the Earth to be banana-shaped.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- 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 [email protected].
For more options, visit https://groups.google.com/d/optout.