Mercurial > vim
diff src/ops.c @ 2896:fd4224d9ee09 v7.3.221
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.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 19 Jun 2011 01:14:29 +0200 |
parents | f169a51f7ead |
children | fe6ad3fd8532 |
line wrap: on
line diff
--- 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, 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, * 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, blockl 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 */