To: vim_dev@googlegroups.com Subject: Patch 9.0.1273 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1273 Problem: "1v" may select block with wrong size. (Evgeni Chasnovski) Solution: Compute "curswant" in the right line. (closes #11925) Files: src/normal.c, src/testdir/test_visual.vim *** ../vim-9.0.1272/src/normal.c 2023-01-16 18:19:01.907301080 +0000 --- src/normal.c 2023-02-01 17:31:19.903435055 +0000 *************** *** 5493,5500 **** } else if (VIsual_mode == Ctrl_V) { update_curswant_force(); ! curwin->w_curswant += + resel_VIsual_vcol * cap->count0 - 1; coladvance(curwin->w_curswant); } else --- 5493,5505 ---- } else if (VIsual_mode == Ctrl_V) { + // Update curswant on the original line, that is where "col" is + // valid. + linenr_T lnum = curwin->w_cursor.lnum; + curwin->w_cursor.lnum = VIsual.lnum; update_curswant_force(); ! curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1; ! curwin->w_cursor.lnum = lnum; coladvance(curwin->w_curswant); } else *** ../vim-9.0.1272/src/testdir/test_visual.vim 2023-01-28 19:18:56.741720608 +0000 --- src/testdir/test_visual.vim 2023-02-01 17:30:19.627433991 +0000 *************** *** 1318,1323 **** --- 1318,1334 ---- endfunc func Test_visual_reselect_with_count() + enew + call setline(1, ['aaaaaa', '✗ bbbb', '✗ bbbb']) + exe "normal! 2Gw\jed" + exe "normal! gg0lP" + call assert_equal(['abbbbaaaaa', '✗bbbb ', '✗ '], getline(1, '$')) + + exe "normal! 1vr." + call assert_equal(['a....aaaaa', '✗.... ', '✗ '], getline(1, '$')) + + bwipe! + " this was causing an illegal memory access let lines =<< trim END *** ../vim-9.0.1272/src/version.c 2023-02-01 15:31:20.271541983 +0000 --- src/version.c 2023-02-01 17:20:16.207382752 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1273, /**/ -- From "know your smileys": :^[/ mean-smiley-with-cigarette /// 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 ///