aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-02-22 14:54:41 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-03-01 04:01:32 -0500
commit4de2957a997bc54a968e40cebc51a42f29afb39c (patch)
tree1e6ba2938671d410197ca5c220bee810713ff29b
parent607240a8bac80f02d812084d3146b4372ddae6dd (diff)
downloadrneovim-4de2957a997bc54a968e40cebc51a42f29afb39c.tar.gz
rneovim-4de2957a997bc54a968e40cebc51a42f29afb39c.tar.bz2
rneovim-4de2957a997bc54a968e40cebc51a42f29afb39c.zip
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. https://github.com/vim/vim/commit/3324d0a86421a634572758dcfde917547f4d4c67
-rw-r--r--src/nvim/ops.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 4ac12e868f..5457400b76 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -842,6 +842,15 @@ static bool is_append_register(int 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`
/// for use in do_put. Should be freed by caller.
yankreg_T *copy_register(int name)
@@ -1152,11 +1161,12 @@ static int put_in_typebuf(
*/
int insert_reg(
int regname,
- int literally /* insert literally, not as if typed */
+ bool literally_arg // insert literally, not as if typed
)
{
int retval = OK;
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
@@ -1326,12 +1336,14 @@ bool get_spec_reg(
/// register contents will be interpreted as commands.
///
/// @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.
///
/// @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);
if (reg->y_array == NULL)
return FAIL;