mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly
Problem: When 'clipboard' is "unnamed" zp and zP do not work correctly.
Solution: Pass -1 to str_to_reg() and fix computing the character width
instead of using the byte length. (Christian Brabandt,
closes vim/vim#8301, closes vim/vim#8317)
6e0b553fa1
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
59edd7c88a
commit
9dc5e2100f
@ -5236,9 +5236,10 @@ 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++) {
|
||||||
|
int charlen = mb_charlen(*ss);
|
||||||
size_t ss_len = strlen(*ss);
|
size_t ss_len = strlen(*ss);
|
||||||
pp[lnum] = cbuf_to_string(*ss, ss_len);
|
pp[lnum] = cbuf_to_string(*ss, ss_len);
|
||||||
maxlen = MAX(maxlen, ss_len);
|
maxlen = MAX(maxlen, (size_t)charlen);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t line_len;
|
size_t line_len;
|
||||||
@ -5246,8 +5247,11 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str,
|
|||||||
start < end + extraline;
|
start < end + extraline;
|
||||||
start += line_len + 1, lnum++) {
|
start += line_len + 1, lnum++) {
|
||||||
assert(end - start >= 0);
|
assert(end - start >= 0);
|
||||||
line_len = (size_t)((char *)xmemscan(start, '\n', (size_t)(end - start)) - start);
|
const char *line_end = xmemscan(start, '\n', (size_t)(end - start));
|
||||||
maxlen = MAX(maxlen, line_len);
|
assert(line_end - start >= 0);
|
||||||
|
line_len = (size_t)(line_end - start);
|
||||||
|
int charlen = start < end ? mb_charlen_len(start, (int)line_len) : 0;
|
||||||
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user