forked from aniani/vim
patch 8.0.1587: inserting from the clipboard doesn't work literally
Problem: inserting from the clipboard doesn't work literally Solution: When pasting from the * or + register always assume literally.
This commit is contained in:
27
src/ops.c
27
src/ops.c
@@ -899,17 +899,21 @@ valid_yank_reg(
|
|||||||
*
|
*
|
||||||
* If regname is 0 and writing, use register 0
|
* If regname is 0 and writing, use register 0
|
||||||
* If regname is 0 and reading, use previous register
|
* If regname is 0 and reading, use previous register
|
||||||
|
*
|
||||||
|
* Return TRUE when the register should be inserted literally (selection or
|
||||||
|
* clipboard).
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
get_yank_register(int regname, int writing)
|
get_yank_register(int regname, int writing)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int ret = FALSE;
|
||||||
|
|
||||||
y_append = FALSE;
|
y_append = FALSE;
|
||||||
if ((regname == 0 || regname == '"') && !writing && y_previous != NULL)
|
if ((regname == 0 || regname == '"') && !writing && y_previous != NULL)
|
||||||
{
|
{
|
||||||
y_current = y_previous;
|
y_current = y_previous;
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
i = regname;
|
i = regname;
|
||||||
if (VIM_ISDIGIT(i))
|
if (VIM_ISDIGIT(i))
|
||||||
@@ -926,10 +930,16 @@ get_yank_register(int regname, int writing)
|
|||||||
#ifdef FEAT_CLIPBOARD
|
#ifdef FEAT_CLIPBOARD
|
||||||
/* When selection is not available, use register 0 instead of '*' */
|
/* When selection is not available, use register 0 instead of '*' */
|
||||||
else if (clip_star.available && regname == '*')
|
else if (clip_star.available && regname == '*')
|
||||||
|
{
|
||||||
i = STAR_REGISTER;
|
i = STAR_REGISTER;
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
/* When clipboard is not available, use register 0 instead of '+' */
|
/* When clipboard is not available, use register 0 instead of '+' */
|
||||||
else if (clip_plus.available && regname == '+')
|
else if (clip_plus.available && regname == '+')
|
||||||
|
{
|
||||||
i = PLUS_REGISTER;
|
i = PLUS_REGISTER;
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_DND
|
#ifdef FEAT_DND
|
||||||
else if (!writing && regname == '~')
|
else if (!writing && regname == '~')
|
||||||
@@ -940,6 +950,7 @@ get_yank_register(int regname, int writing)
|
|||||||
y_current = &(y_regs[i]);
|
y_current = &(y_regs[i]);
|
||||||
if (writing) /* remember the register we write into for do_put() */
|
if (writing) /* remember the register we write into for do_put() */
|
||||||
y_previous = y_current;
|
y_previous = y_current;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEAT_CLIPBOARD) || defined(PROTO)
|
#if defined(FEAT_CLIPBOARD) || defined(PROTO)
|
||||||
@@ -1387,12 +1398,13 @@ put_in_typebuf(
|
|||||||
int
|
int
|
||||||
insert_reg(
|
insert_reg(
|
||||||
int regname,
|
int regname,
|
||||||
int literally) /* insert literally, not as if typed */
|
int literally_arg) /* insert literally, not as if typed */
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
char_u *arg;
|
char_u *arg;
|
||||||
int allocated;
|
int allocated;
|
||||||
|
int literally = literally_arg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is possible to get into an endless loop by having CTRL-R a in
|
* It is possible to get into an endless loop by having CTRL-R a in
|
||||||
@@ -1423,7 +1435,8 @@ insert_reg(
|
|||||||
}
|
}
|
||||||
else /* name or number register */
|
else /* name or number register */
|
||||||
{
|
{
|
||||||
get_yank_register(regname, FALSE);
|
if (get_yank_register(regname, FALSE))
|
||||||
|
literally = TRUE;
|
||||||
if (y_current->y_array == NULL)
|
if (y_current->y_array == NULL)
|
||||||
retval = FAIL;
|
retval = FAIL;
|
||||||
else
|
else
|
||||||
@@ -1580,12 +1593,14 @@ get_spec_reg(
|
|||||||
int
|
int
|
||||||
cmdline_paste_reg(
|
cmdline_paste_reg(
|
||||||
int regname,
|
int regname,
|
||||||
int literally, /* Insert text literally instead of "as typed" */
|
int literally_arg, /* Insert text literally instead of "as typed" */
|
||||||
int remcr) /* don't add CR characters */
|
int remcr) /* don't add CR characters */
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
|
int literally = literally_arg;
|
||||||
|
|
||||||
get_yank_register(regname, FALSE);
|
if (get_yank_register(regname, FALSE))
|
||||||
|
literally = TRUE;
|
||||||
if (y_current->y_array == NULL)
|
if (y_current->y_array == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ void set_expr_line(char_u *new_line);
|
|||||||
char_u *get_expr_line(void);
|
char_u *get_expr_line(void);
|
||||||
char_u *get_expr_line_src(void);
|
char_u *get_expr_line_src(void);
|
||||||
int valid_yank_reg(int regname, int writing);
|
int valid_yank_reg(int regname, int writing);
|
||||||
void get_yank_register(int regname, int writing);
|
int get_yank_register(int regname, int writing);
|
||||||
int may_get_selection(int regname);
|
int may_get_selection(int regname);
|
||||||
void *get_register(int name, int copy);
|
void *get_register(int name, int copy);
|
||||||
void put_register(int name, void *reg);
|
void put_register(int name, void *reg);
|
||||||
@@ -19,7 +19,7 @@ void free_register(void *reg);
|
|||||||
int yank_register_mline(int regname);
|
int yank_register_mline(int regname);
|
||||||
int do_record(int c);
|
int do_record(int c);
|
||||||
int do_execreg(int regname, int colon, int addcr, int silent);
|
int do_execreg(int regname, int colon, int addcr, int silent);
|
||||||
int insert_reg(int regname, int literally);
|
int insert_reg(int regname, int literally_arg);
|
||||||
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
|
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
|
||||||
int cmdline_paste_reg(int regname, int literally, int remcr);
|
int cmdline_paste_reg(int regname, int literally, int remcr);
|
||||||
void adjust_clip_reg(int *rp);
|
void adjust_clip_reg(int *rp);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
" Tests for bracketed paste.
|
" Tests for bracketed paste and other forms of pasting.
|
||||||
|
|
||||||
" Bracketed paste only works with "xterm". Not in GUI.
|
" Bracketed paste only works with "xterm". Not in GUI.
|
||||||
if has('gui_running')
|
if has('gui_running')
|
||||||
@@ -66,6 +66,17 @@ func Test_paste_insert_mode()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
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()
|
func Test_paste_cmdline()
|
||||||
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
|
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
|
||||||
call assert_equal("\"afoo\<CR>barb", getreg(':'))
|
call assert_equal("\"afoo\<CR>barb", getreg(':'))
|
||||||
|
@@ -766,6 +766,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1587,
|
||||||
/**/
|
/**/
|
||||||
1586,
|
1586,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user