]> granicus.if.org Git - vim/commitdiff
patch 8.2.3074: popup_atcursor() uses wrong position with concealing v8.2.3074
authorBram Moolenaar <Bram@vim.org>
Tue, 29 Jun 2021 18:22:32 +0000 (20:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 29 Jun 2021 18:22:32 +0000 (20:22 +0200)
Problem:    popup_atcursor() uses wrong position with concealing.
Solution:   Keep w_wcol in conceal_check_cursor_line(). (closes #8476)

src/edit.c
src/normal.c
src/proto/screen.pro
src/screen.c
src/testdir/dumps/Test_popupwin_atcursor_pos.dump
src/testdir/test_popupwin.vim
src/ui.c
src/version.c

index 9162fe629894580e097fe3c86adcc66785c4125b..d944080300871af00ca978c36afc16acc8c92481 100644 (file)
@@ -147,6 +147,9 @@ edit(
 #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,9 +225,9 @@ edit(
     }
 
 #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();
+    // 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,6 +286,12 @@ edit(
 
     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.
index 18f14ec4e10cd8aa27cb7944e0c6a801fc9b85b2..56f89f518c3babfea91540068b7c848d122af712 100644 (file)
@@ -5747,8 +5747,8 @@ may_start_select(int c)
 n_start_visual_mode(int c)
 {
 #ifdef FEAT_CONCEAL
-    // Check for redraw before changing the state.
-    conceal_check_cursor_line();
+    int cursor_line_was_concealed = curwin->w_p_cole > 0
+                                               && conceal_cursor_line(curwin);
 #endif
 
     VIsual_mode = c;
@@ -5770,8 +5770,8 @@ n_start_visual_mode(int c)
 
     setmouse();
 #ifdef FEAT_CONCEAL
-    // Check for redraw after changing the state.
-    conceal_check_cursor_line();
+    // Check if redraw is needed after changing the state.
+    conceal_check_cursor_line(cursor_line_was_concealed);
 #endif
 
     if (p_smd && msg_silent == 0)
index fc45fa15fef15747c9669a5ff5395008e22fc6c8..6d1993d2b5b528b9a769b9d012580fb65809ed20 100644 (file)
@@ -1,6 +1,6 @@
 /* screen.c */
 int conceal_cursor_line(win_T *wp);
-void conceal_check_cursor_line(void);
+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);
index 7c27e2ca429c8e42116d33a1ac0b257f88383f74..bfb6bf7baf811f50a09a825bc27d8efe7be9ff5c 100644 (file)
@@ -83,16 +83,26 @@ conceal_cursor_line(win_T *wp)
 
 /*
  * 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(void)
+conceal_check_cursor_line(int was_concealed)
 {
-    if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin))
+    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
index a42b6e6ff56c2798b5f8dcba52eeca4cd0895079..3a4f0c2c7f141fb0ca9b4127d451e0d388b4d6a7 100644 (file)
@@ -1,12 +1,12 @@
 |-+0&#ffffff0@59| @14
 |-@59| @14
-|-@25|%|-@16>@|-@14| @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
+|-@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|3|,|4|5| @9|T|o|p| 
+@57|9|,|3|8| @9|T|o|p| 
index 68d7db87ea836ef16aefc1a06dfcc0ee7b728e41..cdfa3a987b20ff65c8dd5ff5779bf7299db1f7dd 100644 (file)
@@ -1462,6 +1462,13 @@ func Test_popup_atcursor_pos()
              \ 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})
index 65ac626d2f12270ad7165149527098d183f54682..b3d125cd5a690b5dc8f691d88a58cc88737c9b26 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -1082,7 +1082,7 @@ ui_cursor_shape_forced(int forced)
 # endif
 
 # ifdef FEAT_CONCEAL
-    conceal_check_cursor_line();
+    conceal_check_cursor_line(FALSE);
 # endif
 }
 
index 125325176be4437ba5a77ade5e5db6834551f47c..f60abafe174a02a3f73e5656dd209920c47ef996 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3074,
 /**/
     3073,
 /**/