On Fr, 01 Jul 2011, Adrien "Axioplase" Piérard wrote:
> colorcolumn seems good, but cursorcolumn is definitely not doing what I
> expect.
> See attached picture.
>
> I have
> cole=2, cocu=nc g:tex_conceal='agm'
> The concealed line is $$\lambda P_1 \vdash 42$$ and the cursor in
> "somewhere in the lambda".
This is a bug. The problem is this line in function win_line() in
screen.c
,----
| if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
`----
The problem is, wp->w_virtcol does not take into account the offset for
the concealed chars.
Here is a patch, that tries to address this issue. This has one problem:
Since one needs to calculate the offset of the line the cursor is at,
all lines that have been drawn before the cursor line, will still be
slightly off. I don't know what the best way is to solve this issue.
Bram, can you give a hint, how to solve this? Is there a better way to
calculate the column offset for the column on which the cursor is? I
don't know the syntax code and the win_line() function is hard to
understand, since it is too large, so any help is appreciated.
regards,
Christian
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/screen.c b/src/screen.c
--- a/src/screen.c
+++ b/src/screen.c
@@ -2557,6 +2557,9 @@
txtcol -= wp->w_skipcol;
else
txtcol -= wp->w_leftcol;
+#ifdef FEAT_CONCEAL
+ txtcol -= wp->w_virtcol_off;
+#endif
if (txtcol >= 0 && txtcol < W_WIDTH(wp))
ScreenAttrs[off + txtcol] = hl_combine_attr(
ScreenAttrs[off + txtcol], hl_attr(HLF_CUC));
@@ -4427,71 +4430,77 @@
}
#ifdef FEAT_CONCEAL
- if ( wp->w_p_cole > 0
- && (wp != curwin || lnum != wp->w_cursor.lnum ||
+ if ( wp->w_p_cole > 0)
+ {
+ if (lnum == curwin->w_cursor.lnum
+ && vcol == curwin->w_virtcol
+ && curwin->w_p_cole > 0 )
+ curwin->w_virtcol_off = vcol_off + n_extra;
+ if ((wp != curwin || lnum != wp->w_cursor.lnum ||
conceal_cursor_line(wp))
&& (syntax_flags & HL_CONCEAL) != 0
&& !(lnum_in_visual_area
&& vim_strchr(wp->w_p_cocu, 'v') == NULL))
- {
- char_attr = conceal_attr;
- if (prev_syntax_id != syntax_seqnr
- && (syn_get_sub_char() != NUL || wp->w_p_cole == 1)
- && wp->w_p_cole != 3)
- {
- /* First time at this concealed item: display one
- * character. */
- if (syn_get_sub_char() != NUL)
- c = syn_get_sub_char();
- else if (lcs_conceal != NUL)
- c = lcs_conceal;
+ {
+ char_attr = conceal_attr;
+ if (prev_syntax_id != syntax_seqnr
+ && (syn_get_sub_char() != NUL || wp->w_p_cole == 1)
+ && wp->w_p_cole != 3)
+ {
+ /* First time at this concealed item: display one
+ * character. */
+ if (syn_get_sub_char() != NUL)
+ c = syn_get_sub_char();
+ else if (lcs_conceal != NUL)
+ c = lcs_conceal;
+ else
+ c = ' ';
+
+ prev_syntax_id = syntax_seqnr;
+
+ if (n_extra > 0)
+ vcol_off += n_extra;
+ vcol += n_extra;
+ if (wp->w_p_wrap && n_extra > 0)
+ {
+# ifdef FEAT_RIGHTLEFT
+ if (wp->w_p_rl)
+ {
+ col -= n_extra;
+ boguscols -= n_extra;
+ }
+ else
+# endif
+ {
+ boguscols += n_extra;
+ col += n_extra;
+ }
+ }
+ n_extra = 0;
+ n_attr = 0;
+ }
+ else if (n_skip == 0)
+ {
+ is_concealing = TRUE;
+ n_skip = 1;
+ }
+# ifdef FEAT_MBYTE
+ mb_c = c;
+ if (enc_utf8 && (*mb_char2len)(c) > 1)
+ {
+ mb_utf8 = TRUE;
+ u8cc[0] = 0;
+ c = 0xc0;
+ }
else
- c = ' ';
-
- prev_syntax_id = syntax_seqnr;
-
- if (n_extra > 0)
- vcol_off += n_extra;
- vcol += n_extra;
- if (wp->w_p_wrap && n_extra > 0)
- {
-# ifdef FEAT_RIGHTLEFT
- if (wp->w_p_rl)
- {
- col -= n_extra;
- boguscols -= n_extra;
- }
- else
-# endif
- {
- boguscols += n_extra;
- col += n_extra;
- }
- }
- n_extra = 0;
- n_attr = 0;
- }
- else if (n_skip == 0)
- {
- is_concealing = TRUE;
- n_skip = 1;
- }
-# ifdef FEAT_MBYTE
- mb_c = c;
- if (enc_utf8 && (*mb_char2len)(c) > 1)
- {
- mb_utf8 = TRUE;
- u8cc[0] = 0;
- c = 0xc0;
+ mb_utf8 = FALSE; /* don't draw as UTF-8 */
+# endif
}
else
- mb_utf8 = FALSE; /* don't draw as UTF-8 */
-# endif
- }
- else
- {
- prev_syntax_id = 0;
- is_concealing = FALSE;
+ {
+ prev_syntax_id = 0;
+ is_concealing = FALSE;
+ }
}
#endif /* FEAT_CONCEAL */
}
@@ -4789,7 +4798,7 @@
draw_color_col = advance_color_col(VCOL_HLC,
&color_cols);
- if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
+ if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol - wp->w_virtcol_off)
ScreenAttrs[off++] = hl_attr(HLF_CUC);
else if (draw_color_col && VCOL_HLC == *color_cols)
ScreenAttrs[off++] = hl_attr(HLF_MC);
@@ -4867,7 +4876,7 @@
vcol_save_attr = -1;
if (draw_state == WL_LINE && !lnum_in_visual_area)
{
- if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol
+ if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol - wp->w_virtcol_off
&& lnum != wp->w_cursor.lnum)
{
vcol_save_attr = char_attr;
diff --git a/src/structs.h b/src/structs.h
--- a/src/structs.h
+++ b/src/structs.h
@@ -1954,6 +1954,10 @@
makes a difference on lines which span
more than one screen line or when
w_leftcol is non-zero */
+#ifdef FEAT_CONCEAL
+ int w_virtcol_off; /* offset for concealed chars of
+ cursor position */
+#endif
/*
* w_wrow and w_wcol specify the cursor position in the window.