Tuesday, December 1, 2015

Re: Fullwidth sign characters, misaligned colorcolumn, and missing visual highlighting

diff --git a/src/screen.c b/src/screen.c
--- a/src/screen.c
+++ b/src/screen.c
@@ -5422,7 +5422,12 @@ win_line(wp, lnum, startrow, endrow, noc
else
/* DBCS: Put second byte in the second screen char. */
ScreenLines[off] = mb_c & 0xff;
- ++vcol;
+ if (draw_state > WL_NR
+#ifdef FEAT_DIFF
+ && filler_todo <= 0
+#endif
+ )
+ ++vcol;
/* When "tocol" is halfway a character, set it to the end of
* the character, otherwise highlighting won't stop. */
if (tocol == vcol)
diff --git a/src/testdir/test_listlbr_utf8.in b/src/testdir/test_listlbr_utf8.in
--- a/src/testdir/test_listlbr_utf8.in
+++ b/src/testdir/test_listlbr_utf8.in
@@ -2,7 +2,7 @@ Test for linebreak and list option in ut

STARTTEST
:so small.vim
-:if !exists("+linebreak") || !has("conceal") | e! test.ok | w! test.out | qa! | endif
+:if !exists("+linebreak") || !has("conceal") || !has("signs") | e! test.ok | w! test.out | qa! | endif
:so mbyte.vim
:if &enc !=? 'utf-8'|:e! test.ok|:w! test.out|qa!|endif
:10new|:vsp|:vert resize 20
@@ -25,6 +25,7 @@ STARTTEST
: $put =g:line
: wincmd p
:endfu
+:"
:let g:test ="Test 1: set linebreak + set list + fancy listchars"
:exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
:redraw!
@@ -45,6 +46,7 @@ STARTTEST
:redraw!
:let line=ScreenChar(winwidth(0),4)
:call DoRecordScreen()
+:"
:let g:test ="Test 4: set linebreak list listchars and concealing"
:let c_defines=['#define ABCDE 1','#define ABCDEF 1','#define ABCDEFG 1','#define ABCDEFGH 1', '#define MSG_MODE_FILE 1','#define MSG_MODE_CONSOLE 2','#define MSG_MODE_FILE_AND_CONSOLE 3','#define MSG_MODE_FILE_THEN_CONSOLE 4']
:call append('$', c_defines)
@@ -56,6 +58,7 @@ STARTTEST
:redraw!
:let line=ScreenChar(winwidth(0),7)
:call DoRecordScreen()
+:"
:let g:test ="Test 5: set linebreak list listchars and concealing part2"
:let c_defines=['bbeeeeee ; some text']
:call append('$', c_defines)
@@ -74,6 +77,7 @@ STARTTEST
:redraw!
:let line=ScreenChar(winwidth(0),1)
:call DoRecordScreen()
+:"
:let g:test ="Test 6: Screenattributes for comment"
:$put =g:test
:call append('$', ' /* and some more */')
@@ -92,10 +96,39 @@ GGlGGlGGlGGlGGlGGlGGlGGlGGlGGl
: call append('$', "Not all attributes are different")
:endif
:set cpo&vim linebreak selection=exclusive
+:"
:let g:test ="Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char"
:$put =g:test
Golong line: 40afoobar aTARGETÃ' at end
:exe "norm! $3B\<C-v>eAx\<Esc>"
+:"
+:let g:test ="Test 9: a multibyte sign and colorcolumn"
+:let attr=[]
+:let attr2=[]
+:$put =''
+:$put ='a b c'
+:$put ='a b c'
+:set list nolinebreak cc=3
+:sign define foo text=ï¼&lsqauo;
+:sign place 1 name=foo line=50 buffer=2
+:norm! 2kztj
+:let line1=line('.')
+0GGlGGlGGlGGl
+:let line2=line('.')
+:let attr2=attr
+:let attr=[]
+0GGlGGlGGlGGl
+:redraw!
+:let line=ScreenChar(winwidth(0),3)
+:call DoRecordScreen()
+:call append('$', ['ScreenAttributes for test9:'])
+:call append('$', ["Line: ".line1. " ". string(g:attr),"Line: ".line2. " ". string(g:attr2)])
+:" expected: attr[2] is different because of colorcolumn
+:if attr[0] != attr2[0] || attr[1] != attr2[1] || attr[2] != attr2[2]
+: call append('$', "Screen attributes are different!")
+:else
+: call append('$', "Screen attributes are the same!")
+:endif
:%w! test.out
:qa!
ENDTEST
diff --git a/src/testdir/test_listlbr_utf8.ok b/src/testdir/test_listlbr_utf8.ok
--- a/src/testdir/test_listlbr_utf8.ok
+++ b/src/testdir/test_listlbr_utf8.ok
@@ -46,3 +46,15 @@ ScreenAttributes for test6:
Attribut 0 and 1 and 3 and 5 are different!
Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char
long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETÃx' at end
+
+a b c
+a b c
+
+Test 9: a multibyte sign and colorcolumn
+ ¶
+ï¼&lsqauo;a b c¶
+ a b c¶
+ScreenAttributes for test9:
+Line: 50 ['0', '0', '72', '0']
+Line: 51 ['0', '0', '72', '0']
+Screen attributes are the same!
On Di, 01 Dez 2015, boss@airbladesoftware.com wrote:
> Hello!
>
> Under certain circumstances the colorcolumn becomes misaligned by one character:
>
> 1. A lign has a sign whose text is a fullwidth character.
> 2. The colorcolumn is a column after the end of the text on the line.
>
> In those circumstances the colorcolumn is drawn at column n-1 instead of n.
>
> Here's how to reproduce:
>
> 1. Define a sign whose text is a fullwidth character (e.g. U+FF0B fullwidth plus sign):
>
> :sign define foo text=+
>
> 2. Open a file in vim.
>
> 3. Place the sign somewhere:
>
> :sign place 1 name=foo line=5 buffer=1
>
> 4. Set the colorcolumn to a number greater than the last colum of the line with the sign:
>
> :set cc=20
>
> 5a. Expected: the colorcolumn is drawn at column 20.
> 5b. Actual: the colorcolumn is drawn at column 19.
>
> Furthermore, the line with the sign is no longer highlighted in a visual selection. To reproduce (following on from above):
>
> 6. Go to line 4, switch to visual line mode, and select a few lines encompassing the line with the sign:
>
> 4GV2j
>
> 7a. Expected: lines 4-6 are highlighted.
> 7b. Actual: line 5 isn't.
>
> Can anyone shed any light on all this?
>

Attached is a patch.

I tried pretty hard to create a test using the existing facilities from
test_listlbr_utf8, since this does already some screen testing.

Unfortunately, it seems the colorcolumn isn't captured by the
screenchar() function (well i guess it is, but since this is only
highlighting, it returns a space). Then I worked around that issue using
screenattr() and while this seems to work, for some reasons it did not
fail the test with unpatched Vims.

I suspect, that the cursor movement is not working correctly, because
when I break into that test I press l twice to move from column 1 to
column 2. But then I thought, it shouldn't hurt to keep that test.

Best,
Christian
--
Bleiben wird von uns nur, was wir dem Allgemeinen geweiht.
-- Karl Gutzkow (Vom Baum der Erkenntnis)

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: