To: vim_dev@googlegroups.com Subject: Patch 9.0.1312 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1312 (after 9.0.1309) Problem: Cursor position wrong when splitting window in insert mode. Solution: Pass the actual mode to win_fix_cursor(). (Luuk van Baal, closes #11999, Files: src/window.c, src/testdir/test_window_cmd.vim *** ../vim-9.0.1311/src/window.c 2023-01-26 11:58:39.610071592 +0000 --- src/window.c 2023-02-15 16:42:48.897899558 +0000 *************** *** 5328,5334 **** if (*p_spk == 'c') // assume cursor position needs updating changed_line_abv_curs(); else ! win_fix_cursor(TRUE); // Now it is OK to parse messages again, which may be needed in // autocommands. --- 5328,5337 ---- if (*p_spk == 'c') // assume cursor position needs updating changed_line_abv_curs(); else ! // Make sure the cursor position is valid, either by moving the cursor ! // or by scrolling the text. ! win_fix_cursor( ! get_real_state() & (MODE_NORMAL|MODE_CMDLINE|MODE_TERMINAL)); // Now it is OK to parse messages again, which may be needed in // autocommands. *************** *** 6782,6788 **** /* * Make sure the cursor position is valid for 'splitkeep'. * If it is not, put the cursor position in the jumplist and move it. ! * If we are not in normal mode, scroll to make valid instead. */ static void win_fix_cursor(int normal) --- 6785,6792 ---- /* * Make sure the cursor position is valid for 'splitkeep'. * If it is not, put the cursor position in the jumplist and move it. ! * If we are not in normal mode ("normal" is zero), make it valid by scrolling ! * instead. */ static void win_fix_cursor(int normal) *** ../vim-9.0.1311/src/testdir/test_window_cmd.vim 2023-02-14 21:56:39.000752403 +0000 --- src/testdir/test_window_cmd.vim 2023-02-15 16:36:47.117736806 +0000 *************** *** 1753,1766 **** " Scroll when cursor becomes invalid in insert mode. norm Lic ! call assert_equal(curpos[0], getcurpos()[0], 'run ' .. run) ! ! " The line number might be one less because of round-off. ! call assert_inrange(curpos[1] - 1, curpos[1], getcurpos()[1], 'run ' .. run) ! ! call assert_equal(curpos[2], getcurpos()[2], 'run ' .. run) ! call assert_equal(curpos[3], getcurpos()[3], 'run ' .. run) ! call assert_equal(curpos[4], getcurpos()[4], 'run ' .. run) " No scroll when topline not equal to 1 only | execute "norm gg5\" | split | wincmd k --- 1753,1759 ---- " Scroll when cursor becomes invalid in insert mode. norm Lic ! call assert_equal(curpos, getcurpos(), 'run ' .. run) " No scroll when topline not equal to 1 only | execute "norm gg5\" | split | wincmd k *** ../vim-9.0.1311/src/version.c 2023-02-15 14:26:21.999922800 +0000 --- src/version.c 2023-02-15 16:40:00.149828381 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1312, /**/ -- "Microsoft is like Coke. It's a secret formula, all the money is from distribution, and their goal is to get Coke everywhere. Open source is like selling water. There are water companies like Perrier and Poland Spring, but you're competing with something that's free." -- Carl Howe /// 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 ///