To: vim_dev@googlegroups.com Subject: Patch 9.0.0482 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0482 Problem: "g0" moves to wrong location with virtual text "above". Solution: Compensate for the extra columns. (closes #11141) Also fix "g$" Files: src/normal.c, src/move.c, src/proto/move.pro, src/testdir/test_textprop.vim, src/testdir/dumps/Test_prop_with_text_above_1a.dump, src/testdir/dumps/Test_prop_with_text_above_1b.dump *** ../vim-9.0.0481/src/normal.c 2022-09-05 16:53:17.115566769 +0100 --- src/normal.c 2022-09-16 20:44:15.493634226 +0100 *************** *** 5491,5499 **** { if (resel_VIsual_line_count <= 1) { ! validate_virtcol(); ! curwin->w_curswant = curwin->w_virtcol ! + resel_VIsual_vcol * cap->count0 - 1; } else curwin->w_curswant = resel_VIsual_vcol; --- 5491,5498 ---- { if (resel_VIsual_line_count <= 1) { ! update_curswant_force(); ! curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1; } else curwin->w_curswant = resel_VIsual_vcol; *************** *** 5506,5514 **** } else if (VIsual_mode == Ctrl_V) { ! validate_virtcol(); ! curwin->w_curswant = curwin->w_virtcol ! + resel_VIsual_vcol * cap->count0 - 1; coladvance(curwin->w_curswant); } else --- 5505,5512 ---- } else if (VIsual_mode == Ctrl_V) { ! update_curswant_force(); ! curwin->w_curswant += + resel_VIsual_vcol * cap->count0 - 1; coladvance(curwin->w_curswant); } else *************** *** 5735,5747 **** cap->oap->inclusive = FALSE; if (curwin->w_p_wrap && curwin->w_width != 0) { ! int width1 = curwin->w_width - curwin_col_off(); ! int width2 = width1 + curwin_col_off2(); validate_virtcol(); i = 0; ! if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0) ! i = (curwin->w_virtcol - width1) / width2 * width2 + width1; } else i = curwin->w_leftcol; --- 5733,5751 ---- cap->oap->inclusive = FALSE; if (curwin->w_p_wrap && curwin->w_width != 0) { ! int width1 = curwin->w_width - curwin_col_off(); ! int width2 = width1 + curwin_col_off2(); ! int virtcol; validate_virtcol(); + virtcol = curwin->w_virtcol + #ifdef FEAT_PROP_POPUP + - curwin->w_virtcol_first_char + #endif + ; i = 0; ! if (virtcol >= (colnr_T)width1 && width2 > 0) ! i = (virtcol - width1) / width2 * width2 + width1; } else i = curwin->w_leftcol; *************** *** 5815,5838 **** { int width1 = curwin->w_width - col_off; int width2 = width1 + curwin_col_off2(); validate_virtcol(); i = width1 - 1; ! if (curwin->w_virtcol >= (colnr_T)width1) ! i += ((curwin->w_virtcol - width1) / width2 + 1) * width2; coladvance((colnr_T)i); // Make sure we stick in this column. ! validate_virtcol(); ! curwin->w_curswant = curwin->w_virtcol; ! curwin->w_set_curswant = FALSE; if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) { // Check for landing on a character that got split at // the end of the line. We do not want to advance to // the next screen line. ! if (curwin->w_virtcol > (colnr_T)i) --curwin->w_cursor.col; } } --- 5819,5850 ---- { int width1 = curwin->w_width - col_off; int width2 = width1 + curwin_col_off2(); + int virtcol; validate_virtcol(); + virtcol = curwin->w_virtcol + #ifdef FEAT_PROP_POPUP + - curwin->w_virtcol_first_char + #endif + ; i = width1 - 1; ! if (virtcol >= (colnr_T)width1) ! i += ((virtcol - width1) / width2 + 1) * width2; coladvance((colnr_T)i); // Make sure we stick in this column. ! update_curswant_force(); if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) { // Check for landing on a character that got split at // the end of the line. We do not want to advance to // the next screen line. ! if (curwin->w_virtcol ! #ifdef FEAT_PROP_POPUP ! - curwin->w_virtcol_first_char ! #endif ! > (colnr_T)i) --curwin->w_cursor.col; } } *************** *** 5860,5868 **** } // Make sure we stick in this column. ! validate_virtcol(); ! curwin->w_curswant = curwin->w_virtcol; ! curwin->w_set_curswant = FALSE; } } --- 5872,5878 ---- } // Make sure we stick in this column. ! update_curswant_force(); } } *** ../vim-9.0.0481/src/move.c 2022-09-12 17:50:42.782378262 +0100 --- src/move.c 2022-09-16 20:20:24.902776103 +0100 *************** *** 470,488 **** return FALSE; } void ! update_curswant(void) { ! if (curwin->w_set_curswant) ! { ! validate_virtcol(); ! curwin->w_curswant = curwin->w_virtcol #ifdef FEAT_PROP_POPUP ! - curwin->w_virtcol_first_char #endif ! ; ! curwin->w_set_curswant = FALSE; ! } } /* --- 470,498 ---- return FALSE; } + /* + * Update w_curswant. + */ void ! update_curswant_force(void) { ! validate_virtcol(); ! curwin->w_curswant = curwin->w_virtcol #ifdef FEAT_PROP_POPUP ! - curwin->w_virtcol_first_char #endif ! ; ! curwin->w_set_curswant = FALSE; ! } ! ! /* ! * Update w_curswant if w_set_curswant is set. ! */ ! void ! update_curswant(void) ! { ! if (curwin->w_set_curswant) ! update_curswant_force(); } /* *** ../vim-9.0.0481/src/proto/move.pro 2022-08-12 13:05:27.563326167 +0100 --- src/proto/move.pro 2022-09-16 20:20:21.458784582 +0100 *************** *** 2,7 **** --- 2,8 ---- void redraw_for_cursorline(win_T *wp); void update_topline_redraw(void); void update_topline(void); + void update_curswant_force(void); void update_curswant(void); void check_cursor_moved(win_T *wp); void changed_window_setting(void); *** ../vim-9.0.0481/src/testdir/test_textprop.vim 2022-09-15 19:43:48.908462529 +0100 --- src/testdir/test_textprop.vim 2022-09-16 20:46:48.225355198 +0100 *************** *** 2869,2874 **** --- 2869,2879 ---- let buf = RunVimInTerminal('-S XscriptPropsWithTextAbove', #{rows: 9, cols: 60}) call VerifyScreenDump(buf, 'Test_prop_with_text_above_1', {}) + call term_sendkeys(buf, "ggg$") + call VerifyScreenDump(buf, 'Test_prop_with_text_above_1a', {}) + call term_sendkeys(buf, "g0") + call VerifyScreenDump(buf, 'Test_prop_with_text_above_1b', {}) + call term_sendkeys(buf, "ggI") call VerifyScreenDump(buf, 'Test_prop_with_text_above_2', {}) call term_sendkeys(buf, "inserted \") *** ../vim-9.0.0481/src/testdir/dumps/Test_prop_with_text_above_1a.dump 2022-09-16 20:50:04.312985702 +0100 --- src/testdir/dumps/Test_prop_with_text_above_1a.dump 2022-09-16 20:46:56.861339161 +0100 *************** *** 0 **** --- 1,9 ---- + |f+0&#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @42 + |s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41 + |o+0&#ffffff0|n|e| |t|w>o| @52 + |t|h|r|e@1| |f|o|u|r| @49 + @3|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @43 + |f+0&#ffffff0|i|v|e| |s|i|x| @51 + |~+0#4040ff13&| @58 + |~| @58 + | +0#0000000&@41|1|,|7|-|1|2|7| @6|A|l@1| *** ../vim-9.0.0481/src/testdir/dumps/Test_prop_with_text_above_1b.dump 2022-09-16 20:50:04.316985694 +0100 --- src/testdir/dumps/Test_prop_with_text_above_1b.dump 2022-09-16 20:46:58.009337028 +0100 *************** *** 0 **** --- 1,9 ---- + |f+0&#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @42 + |s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41 + >o+0&#ffffff0|n|e| |t|w|o| @52 + |t|h|r|e@1| |f|o|u|r| @49 + @3|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @43 + |f+0&#ffffff0|i|v|e| |s|i|x| @51 + |~+0#4040ff13&| @58 + |~| @58 + | +0#0000000&@41|1|,|1|-|1|2|1| @6|A|l@1| *** ../vim-9.0.0481/src/version.c 2022-09-16 19:04:19.961886501 +0100 --- src/version.c 2022-09-16 20:49:08.709091577 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 482, /**/ -- Warning label on a superhero Halloween costume: "Caution: Cape does not enable user to fly." /// 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 ///