mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 17:42:37 +00:00
Merge pull request #32374 from zeertzjq/vim-8.2.2933
vim-patch:8.2.{2933,2934,2935},9.1.1083
This commit is contained in:
@@ -5236,18 +5236,37 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str,
|
|||||||
// Find the end of each line and save it into the array.
|
// Find the end of each line and save it into the array.
|
||||||
if (str_list) {
|
if (str_list) {
|
||||||
for (char **ss = (char **)str; *ss != NULL; ss++, lnum++) {
|
for (char **ss = (char **)str; *ss != NULL; ss++, lnum++) {
|
||||||
size_t ss_len = strlen(*ss);
|
pp[lnum] = cstr_to_string(*ss);
|
||||||
pp[lnum] = cbuf_to_string(*ss, ss_len);
|
if (yank_type == kMTBlockWise) {
|
||||||
maxlen = MAX(maxlen, ss_len);
|
size_t charlen = mb_string2cells(*ss);
|
||||||
|
maxlen = MAX(maxlen, charlen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t line_len;
|
size_t line_len;
|
||||||
for (const char *start = str, *end = str + len;
|
for (const char *start = str, *end = str + len;
|
||||||
start < end + extraline;
|
start < end + extraline;
|
||||||
start += line_len + 1, lnum++) {
|
start += line_len + 1, lnum++) {
|
||||||
assert(end - start >= 0);
|
int charlen = 0;
|
||||||
line_len = (size_t)((char *)xmemscan(start, '\n', (size_t)(end - start)) - start);
|
|
||||||
maxlen = MAX(maxlen, line_len);
|
const char *line_end = start;
|
||||||
|
while (line_end < end) { // find the end of the line
|
||||||
|
if (*line_end == '\n') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (yank_type == kMTBlockWise) {
|
||||||
|
charlen += utf_ptr2cells_len(line_end, (int)(end - line_end));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*line_end == NUL) {
|
||||||
|
line_end++; // registers can have NUL chars
|
||||||
|
} else {
|
||||||
|
line_end += utf_ptr2len_len(line_end, (int)(end - line_end));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(line_end - start >= 0);
|
||||||
|
line_len = (size_t)(line_end - start);
|
||||||
|
maxlen = MAX(maxlen, (size_t)charlen);
|
||||||
|
|
||||||
// When appending, copy the previous line and free it after.
|
// When appending, copy the previous line and free it after.
|
||||||
size_t extra = append ? pp[--lnum].size : 0;
|
size_t extra = append ? pp[--lnum].size : 0;
|
||||||
@@ -5255,7 +5274,9 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str,
|
|||||||
if (extra > 0) {
|
if (extra > 0) {
|
||||||
memcpy(s, pp[lnum].data, extra);
|
memcpy(s, pp[lnum].data, extra);
|
||||||
}
|
}
|
||||||
memcpy(s + extra, start, line_len);
|
if (line_len > 0) {
|
||||||
|
memcpy(s + extra, start, line_len);
|
||||||
|
}
|
||||||
size_t s_len = extra + line_len;
|
size_t s_len = extra + line_len;
|
||||||
|
|
||||||
if (append) {
|
if (append) {
|
||||||
|
|||||||
@@ -435,6 +435,23 @@ func Test_set_register()
|
|||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for blockwise register width calculations
|
||||||
|
func Test_set_register_blockwise_width()
|
||||||
|
" Test for regular calculations and overriding the width
|
||||||
|
call setreg('a', "12\n1234\n123", 'b')
|
||||||
|
call assert_equal("\<c-v>4", getreginfo('a').regtype)
|
||||||
|
call setreg('a', "12\n1234\n123", 'b1')
|
||||||
|
call assert_equal("\<c-v>1", getreginfo('a').regtype)
|
||||||
|
call setreg('a', "12\n1234\n123", 'b6')
|
||||||
|
call assert_equal("\<c-v>6", getreginfo('a').regtype)
|
||||||
|
|
||||||
|
" Test for Unicode parsing
|
||||||
|
call setreg('a', "z😅😅z\n12345", 'b')
|
||||||
|
call assert_equal("\<c-v>6", getreginfo('a').regtype)
|
||||||
|
call setreg('a', ["z😅😅z", "12345"], 'b')
|
||||||
|
call assert_equal("\<c-v>6", getreginfo('a').regtype)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for clipboard registers (* and +)
|
" Test for clipboard registers (* and +)
|
||||||
func Test_clipboard_regs()
|
func Test_clipboard_regs()
|
||||||
throw 'skipped: needs clipboard=autoselect,autoselectplus'
|
throw 'skipped: needs clipboard=autoselect,autoselectplus'
|
||||||
|
|||||||
Reference in New Issue
Block a user