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.
3324d0a864
This commit is contained in:
Jan Edmund Lazo 2020-02-22 14:54:41 -05:00
parent 607240a8ba
commit 4de2957a99
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
1 changed files with 15 additions and 3 deletions

View File

@ -842,6 +842,15 @@ static bool is_append_register(int regname)
return ASCII_ISUPPER(regname); return ASCII_ISUPPER(regname);
} }
/// @see get_yank_register
/// @returns true when register should be inserted literally
/// (selection or clipboard)
static inline bool is_literal_register(int regname)
FUNC_ATTR_CONST
{
return regname == '*' || regname == '+';
}
/// Returns a copy of contents in register `name` /// Returns a copy of contents in register `name`
/// for use in do_put. Should be freed by caller. /// for use in do_put. Should be freed by caller.
yankreg_T *copy_register(int name) yankreg_T *copy_register(int name)
@ -1152,11 +1161,12 @@ static int put_in_typebuf(
*/ */
int insert_reg( int insert_reg(
int regname, int regname,
int literally /* insert literally, not as if typed */ bool literally_arg // insert literally, not as if typed
) )
{ {
int retval = OK; int retval = OK;
bool allocated; bool allocated;
const bool literally = literally_arg || is_literal_register(regname);
/* /*
* 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
@ -1326,12 +1336,14 @@ bool get_spec_reg(
/// register contents will be interpreted as commands. /// register contents will be interpreted as commands.
/// ///
/// @param regname Register name. /// @param regname Register name.
/// @param literally Insert text literally instead of "as typed". /// @param literally_arg Insert text literally instead of "as typed".
/// @param remcr When true, don't add CR characters. /// @param remcr When true, don't add CR characters.
/// ///
/// @returns FAIL for failure, OK otherwise /// @returns FAIL for failure, OK otherwise
bool cmdline_paste_reg(int regname, bool literally, bool remcr) bool cmdline_paste_reg(int regname, bool literally_arg, bool remcr)
{ {
const bool literally = literally_arg || is_literal_register(regname);
yankreg_T *reg = get_yank_register(regname, YREG_PASTE); yankreg_T *reg = get_yank_register(regname, YREG_PASTE);
if (reg->y_array == NULL) if (reg->y_array == NULL)
return FAIL; return FAIL;