From d44347f1e7791ead2d90b1fda06d9f4e325d912e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 19 Jun 2011 01:14:29 +0200 Subject: updated for version 7.3.221 Problem: Text from the clipboard is sometimes handled as linewise, but not consistently. Solution: Assume the text is linewise when it ends in a CR or NL. --- src/ops.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/ops.c') diff --git a/src/ops.c b/src/ops.c index c41f84456..8c235220e 100644 --- a/src/ops.c +++ b/src/ops.c @@ -5733,7 +5733,9 @@ clip_get_selection(cbd) } } -/* Convert from the GUI selection string into the '*'/'+' register */ +/* + * Convert from the GUI selection string into the '*'/'+' register. + */ void clip_yank_selection(type, str, len, cbd) int type; @@ -6090,9 +6092,6 @@ write_reg_contents_ex(name, str, maxlen, must_append, yank_type, block_len) if (yank_type == MBLOCK) yank_type = MAUTO; #endif - if (yank_type == MAUTO) - yank_type = ((len > 0 && (str[len - 1] == '\n' || str[len - 1] == '\r')) - ? MLINE : MCHAR); str_to_reg(y_current, yank_type, str, len, block_len); # ifdef FEAT_CLIPBOARD @@ -6113,13 +6112,14 @@ write_reg_contents_ex(name, str, maxlen, must_append, yank_type, block_len) * is appended. */ static void -str_to_reg(y_ptr, type, str, len, blocklen) +str_to_reg(y_ptr, yank_type, str, len, blocklen) struct yankreg *y_ptr; /* pointer to yank register */ - int type; /* MCHAR, MLINE or MBLOCK */ + int yank_type; /* MCHAR, MLINE, MBLOCK, MAUTO */ char_u *str; /* string to put in register */ long len; /* length of string */ long blocklen; /* width of Visual block */ { + int type; /* MCHAR, MLINE or MBLOCK */ int lnum; long start; long i; @@ -6136,6 +6136,12 @@ str_to_reg(y_ptr, type, str, len, blocklen) if (y_ptr->y_array == NULL) /* NULL means empty register */ y_ptr->y_size = 0; + if (yank_type == MAUTO) + type = ((len > 0 && (str[len - 1] == NL || str[len - 1] == CAR)) + ? MLINE : MCHAR); + else + type = yank_type; + /* * Count the number of lines within the string */ -- cgit v1.2.1