aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-18 02:39:07 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-02-18 14:49:05 +0100
commit308ccb6f5e40ba1dbe4abfebc9df3399d7f17504 (patch)
tree4cf89d29a05f58b4e7b97489df8c66f31a18da47 /src/nvim/ops.c
parentb49a74a1afe9740f18ca419dade45705da5bec46 (diff)
downloadrneovim-308ccb6f5e40ba1dbe4abfebc9df3399d7f17504.tar.gz
rneovim-308ccb6f5e40ba1dbe4abfebc9df3399d7f17504.tar.bz2
rneovim-308ccb6f5e40ba1dbe4abfebc9df3399d7f17504.zip
cmdline: CTRL-R: <Space> instead of CR between lines.
^M isn't any more "correct" than space: the "technically correct" interpretation is to execute the first line that is seen (and this is what happens on middle-click paste in Vim). ^M is only intended to defuse the newline, so that the user can review the command. We can do that with a space instead, and then the command can be executed without having to fix it up first.
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d58c8700ca..2f45795812 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1260,16 +1260,16 @@ int get_spec_reg(
/// Paste a yank register into the command line.
/// Only for non-special registers.
-/// Used by CTRL-R command in command-line mode
+/// Used by CTRL-R in command-line mode.
/// insert_reg() can't be used here, because special characters from the
/// register contents will be interpreted as commands.
///
/// @param regname Register name.
/// @param literally Insert text literally instead of "as typed".
-/// @param remcr When true, don't add CR characters.
+/// @param remspc When true, don't add <Space> 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, bool remspc)
{
yankreg_T *reg = get_yank_register(regname, YREG_PASTE);
if (reg->y_array == NULL)
@@ -1278,10 +1278,9 @@ bool cmdline_paste_reg(int regname, bool literally, bool remcr)
for (size_t i = 0; i < reg->y_size; i++) {
cmdline_paste_str(reg->y_array[i], literally);
- // Insert ^M between lines and after last line if type is kMTLineWise.
- // Don't do this when "remcr" is true.
- if ((reg->y_type == kMTLineWise || i < reg->y_size - 1) && !remcr) {
- cmdline_paste_str((char_u *)"\r", literally);
+ // Insert space between lines, unless `remspc` is true.
+ if (i < reg->y_size - 1 && !remspc) {
+ cmdline_paste_str((char_u *)" ", literally);
}
/* Check for CTRL-C, in case someone tries to paste a few thousand