To: vim_dev@googlegroups.com Subject: Patch 8.2.3454 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3454 Problem: Using a count with "gp" leave cursor in wrong position. (Naohiro Ono) Solution: Count the inserted lines. (closes #8899) Files: src/register.c, src/testdir/test_put.vim *** ../vim-8.2.3453/src/register.c 2021-09-14 18:55:47.864129826 +0200 --- src/register.c 2021-09-22 16:25:12.896230552 +0200 *************** *** 2065,2070 **** --- 2065,2072 ---- } else { + linenr_T new_lnum = new_cursor.lnum; + // Insert at least one line. When y_type is MCHAR, break the first // line in two. for (cnt = 1; cnt <= count; ++cnt) *************** *** 2085,2090 **** --- 2087,2093 ---- STRCAT(newp, ptr); // insert second line ml_append(lnum, newp, (colnr_T)0, FALSE); + ++new_lnum; vim_free(newp); oldp = ml_get(lnum); *************** *** 2103,2112 **** for (; i < y_size; ++i) { ! if ((y_type != MCHAR || i < y_size - 1) ! && ml_append(lnum, y_array[i], (colnr_T)0, FALSE) == FAIL) goto error; lnum++; ++nr_lines; if (flags & PUT_FIXINDENT) --- 2106,2118 ---- for (; i < y_size; ++i) { ! if (y_type != MCHAR || i < y_size - 1) ! { ! if (ml_append(lnum, y_array[i], (colnr_T)0, FALSE) == FAIL) goto error; + new_lnum++; + } lnum++; ++nr_lines; if (flags & PUT_FIXINDENT) *************** *** 2138,2143 **** --- 2144,2151 ---- lendiff -= (int)STRLEN(ml_get(lnum)); } } + if (cnt == 1) + new_lnum = lnum; } error: *************** *** 2195,2201 **** } else { ! curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = col; } } --- 2203,2209 ---- } else { ! curwin->w_cursor.lnum = new_lnum; curwin->w_cursor.col = col; } } *** ../vim-8.2.3453/src/testdir/test_put.vim 2020-09-04 21:18:40.484161926 +0200 --- src/testdir/test_put.vim 2021-09-22 16:35:32.402565639 +0200 *************** *** 122,125 **** --- 122,135 ---- close! endfunc + func Test_gp_with_count_leaves_cursor_at_end() + new + call setline(1, '<---->') + call setreg('@', "foo\nbar", 'c') + exe "normal 1G3|3gpix\" + call assert_equal(['<--foo', 'barfoo', 'barfoo', 'barx-->'], getline(1, '$')) + + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3453/src/version.c 2021-09-22 14:18:09.313222517 +0200 --- src/version.c 2021-09-22 16:21:34.612734116 +0200 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3454, /**/ -- hundred-and-one symptoms of being an internet addict: 50. The last girl you picked up was only a jpeg. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///