Merge #6137 from justinmk/cmdline-ctrl-r

cmdline: CTRL-R: Omit trailing ^M character
This commit is contained in:
Justin M. Keyes
2017-02-19 14:20:52 +01:00
committed by GitHub
4 changed files with 39 additions and 4 deletions

View File

@@ -1260,7 +1260,7 @@ 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.
///
@@ -1278,9 +1278,8 @@ 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) {
// Insert ^M between lines, unless `remcr` is true.
if (i < reg->y_size - 1 && !remcr) {
cmdline_paste_str((char_u *)"\r", literally);
}