To: vim_dev@googlegroups.com Subject: Patch 8.2.3074 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3074 Problem: popup_atcursor() uses wrong position with concealing. Solution: Keep w_wcol in conceal_check_cursor_line(). (closes #8476) Files: src/screen.c, src/proto/screen.pro, src/normal.c, src/edit.c, src/ui.c, src/testdir/test_popupwin.vim, src/testdir/dumps/Test_popupwin_atcursor_pos.dump *** ../vim-8.2.3073/src/screen.c 2021-06-02 13:28:11.435120452 +0200 --- src/screen.c 2021-06-29 20:08:30.172761283 +0200 *************** *** 83,98 **** /* * Check if the cursor line needs to be redrawn because of 'concealcursor'. */ void ! conceal_check_cursor_line(void) { ! if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)) { need_cursor_line_redraw = TRUE; // Need to recompute cursor column, e.g., when starting Visual mode // without concealing. curs_columns(TRUE); } } #endif --- 83,108 ---- /* * Check if the cursor line needs to be redrawn because of 'concealcursor'. + * To be called after changing the state, "was_concealed" is the value of + * "conceal_cursor_line()" before the change. + * " */ void ! conceal_check_cursor_line(int was_concealed) { ! if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin) != was_concealed) { + int wcol = curwin->w_wcol; + need_cursor_line_redraw = TRUE; // Need to recompute cursor column, e.g., when starting Visual mode // without concealing. curs_columns(TRUE); + + // When concealing now w_wcol will be computed wrong, keep the previous + // value, it will be updated in win_line(). + if (!was_concealed) + curwin->w_wcol = wcol; } } #endif *** ../vim-8.2.3073/src/proto/screen.pro 2021-03-03 13:25:59.535913158 +0100 --- src/proto/screen.pro 2021-06-29 20:01:14.061335774 +0200 *************** *** 1,6 **** /* screen.c */ int conceal_cursor_line(win_T *wp); ! void conceal_check_cursor_line(void); int get_wcr_attr(win_T *wp); void win_draw_end(win_T *wp, int c1, int c2, int draw_margin, int row, int endrow, hlf_T hl); int compute_foldcolumn(win_T *wp, int col); --- 1,6 ---- /* screen.c */ int conceal_cursor_line(win_T *wp); ! void conceal_check_cursor_line(int was_concealed); int get_wcr_attr(win_T *wp); void win_draw_end(win_T *wp, int c1, int c2, int draw_margin, int row, int endrow, hlf_T hl); int compute_foldcolumn(win_T *wp, int col); *** ../vim-8.2.3073/src/normal.c 2021-06-27 22:03:28.645707721 +0200 --- src/normal.c 2021-06-29 20:05:23.181027939 +0200 *************** *** 5747,5754 **** n_start_visual_mode(int c) { #ifdef FEAT_CONCEAL ! // Check for redraw before changing the state. ! conceal_check_cursor_line(); #endif VIsual_mode = c; --- 5747,5754 ---- n_start_visual_mode(int c) { #ifdef FEAT_CONCEAL ! int cursor_line_was_concealed = curwin->w_p_cole > 0 ! && conceal_cursor_line(curwin); #endif VIsual_mode = c; *************** *** 5770,5777 **** setmouse(); #ifdef FEAT_CONCEAL ! // Check for redraw after changing the state. ! conceal_check_cursor_line(); #endif if (p_smd && msg_silent == 0) --- 5770,5777 ---- setmouse(); #ifdef FEAT_CONCEAL ! // Check if redraw is needed after changing the state. ! conceal_check_cursor_line(cursor_line_was_concealed); #endif if (p_smd && msg_silent == 0) *** ../vim-8.2.3073/src/edit.c 2021-01-28 11:07:40.881497383 +0100 --- src/edit.c 2021-06-29 20:03:48.913152012 +0200 *************** *** 147,152 **** --- 147,155 ---- #ifdef FEAT_JOB_CHANNEL int cmdchar_todo = cmdchar; #endif + #ifdef FEAT_CONCEAL + int cursor_line_was_concealed; + #endif // Remember whether editing was restarted after CTRL-O. did_restart_edit = restart_edit; *************** *** 222,230 **** } #ifdef FEAT_CONCEAL ! // Check if the cursor line needs redrawing before changing State. If ! // 'concealcursor' is "n" it needs to be redrawn without concealing. ! conceal_check_cursor_line(); #endif /* --- 225,233 ---- } #ifdef FEAT_CONCEAL ! // Check if the cursor line was concealed before changing State. ! cursor_line_was_concealed = curwin->w_p_cole > 0 ! && conceal_cursor_line(curwin); #endif /* *************** *** 283,288 **** --- 286,297 ---- stop_insert_mode = FALSE; + #ifdef FEAT_CONCEAL + // Check if the cursor line needs redrawing after changing State. If + // 'concealcursor' is "n" it needs to be redrawn without concealing. + conceal_check_cursor_line(cursor_line_was_concealed); + #endif + /* * Need to recompute the cursor position, it might move when the cursor is * on a TAB or special character. *** ../vim-8.2.3073/src/ui.c 2021-06-07 22:04:48.406620074 +0200 --- src/ui.c 2021-06-29 20:06:21.872946894 +0200 *************** *** 1082,1088 **** # endif # ifdef FEAT_CONCEAL ! conceal_check_cursor_line(); # endif } --- 1082,1088 ---- # endif # ifdef FEAT_CONCEAL ! conceal_check_cursor_line(FALSE); # endif } *** ../vim-8.2.3073/src/testdir/test_popupwin.vim 2021-06-22 19:52:23.901800877 +0200 --- src/testdir/test_popupwin.vim 2021-06-29 20:20:00.391645121 +0200 *************** *** 1462,1467 **** --- 1462,1474 ---- \ moved: range(3), \ mousemoved: range(3), \ }) + + normal 9G27|Rconcealed X + syn match Hidden /concealed/ conceal + set conceallevel=2 concealcursor=n + redraw + normal 0fX + call popup_atcursor('mark', {}) END call writefile(lines, 'XtestPopupAtcursorPos') let buf = RunVimInTerminal('-S XtestPopupAtcursorPos', #{rows: 12}) *** ../vim-8.2.3073/src/testdir/dumps/Test_popupwin_atcursor_pos.dump 2019-11-09 15:24:42.000000000 +0100 --- src/testdir/dumps/Test_popupwin_atcursor_pos.dump 2021-06-29 20:20:05.535636369 +0200 *************** *** 1,12 **** |-+0&#ffffff0@59| @14 |-@59| @14 ! |-@25|%|-@16>@|-@14| @14 |-@25|f+0#0000001#ffd7ff255|i|R|S|t| |-+0#0000000#ffffff0@6|F+0#0000001#ffd7ff255|i|r|s|t| |-+0#0000000#ffffff0@14| @14 |-@25|s+0#0000001#ffd7ff255|e|C|O|n|d|-+0#0000000#ffffff0@6|S+0#0000001#ffd7ff255|e|c|o|n|D|-+0#0000000#ffffff0@14| @14 |-@59| @14 |-@1|f+0#0000001#ffd7ff255|i|r|s|t| |-+0#0000000#ffffff0@6|F+0#0000001#ffd7ff255|I|r|s|T| |-+0#0000000#ffffff0@38| @14 ! |-@1|s+0#0000001#ffd7ff255|e|c|o|n|d|-+0#0000000#ffffff0@6|S+0#0000001#ffd7ff255|E|c|o|N|D|-+0#0000000#ffffff0@38| @14 ! |-@1|#|-@16|&|-@38| @14 |-@59| @14 |-@59| @14 ! @57|3|,|4|5| @9|T|o|p| --- 1,12 ---- |-+0&#ffffff0@59| @14 |-@59| @14 ! |-@25|%|-@16|@|-@14| @14 |-@25|f+0#0000001#ffd7ff255|i|R|S|t| |-+0#0000000#ffffff0@6|F+0#0000001#ffd7ff255|i|r|s|t| |-+0#0000000#ffffff0@14| @14 |-@25|s+0#0000001#ffd7ff255|e|C|O|n|d|-+0#0000000#ffffff0@6|S+0#0000001#ffd7ff255|e|c|o|n|D|-+0#0000000#ffffff0@14| @14 |-@59| @14 |-@1|f+0#0000001#ffd7ff255|i|r|s|t| |-+0#0000000#ffffff0@6|F+0#0000001#ffd7ff255|I|r|s|T| |-+0#0000000#ffffff0@38| @14 ! |-@1|s+0#0000001#ffd7ff255|e|c|o|n|d|-+0#0000000#ffffff0@6|S+0#0000001#ffd7ff255|E|c|o|N|D|-+0#0000000#ffffff0@6|m+0#0000001#ffd7ff255|a|r|k|-+0#0000000#ffffff0@27| @14 ! |-@1|#|-@16|&|-@4| @1>X|-@21| @23 |-@59| @14 |-@59| @14 ! @57|9|,|3|8| @9|T|o|p| *** ../vim-8.2.3073/src/version.c 2021-06-29 18:54:32.288672327 +0200 --- src/version.c 2021-06-29 20:21:44.843466618 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3074, /**/ -- There is a difference between "should work" and "does work", it's called testing. /// 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 ///