[bug][patch] matchaddpos() may not draw overldapped pos.

47 views
Skip to first unread message

Ozaki Kiichi

unread,
Oct 13, 2016, 4:11:25 PM10/13/16
to vim_dev
Hi.

This is matchaddpos() problem.

[repro steps]

vim -Nu NONE

i1234567890<Esc>
:call matchaddpos('ErrorMsg', [[1, 1, 5], [1, 3, 5]])

expected: colored 1~7 ("12345" and "34567"; pos [1, 1, 5] and [1, 3, 5], overlapped "345")

actual: colored 1~5 ("12345"; only first pos [1, 1, 5])

This problem occurs when overlapping more than 1 char.
e.g. [[1, 1, 5], [1, 5, 5]] is no problem.

[cause]

https://github.com/vim/vim/blob/fd89d7e/src/screen.c#L7770-L7771

On processing second pos [1, 3, 5], mincol is 5 (end of first pos col).
Thus, col (== 3) is less then mincol, and second pos is skipped.

I think that the case of "col < mincol < col + len -1" should be also processed.

[patch]

https://gist.github.com/ichizok/f34c9018f5e9e452d3bc78cc9026a720

Thank you.
- Ozaki Kiichi

Bram Moolenaar

unread,
Oct 14, 2016, 2:41:58 PM10/14/16
to Ozaki Kiichi, vim_dev
Can you please add a test that fails without the patch?

--
ROBIN: (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN: Oh ... wacho!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

h_east

unread,
Oct 14, 2016, 10:49:15 PM10/14/16
to vim_dev, gclien...@gmail.com
Hi Bram and Kiichi,

2016-10-15(Sat) 3:41:58 UTC+9 Bram Moolenaar:


> Ozaki Kiichi wrote:
>
> > This is matchaddpos() problem.
> >
> > [repro steps]
> >
> > vim -Nu NONE
> >
> > i1234567890<Esc>
> > :call matchaddpos('ErrorMsg', [[1, 1, 5], [1, 3, 5]])
> >
> > expected: colored 1~7 ("12345" and "34567"; pos [1, 1, 5] and [1, 3, 5], overlapped "345")
> >
> > actual: colored 1~5 ("12345"; only first pos [1, 1, 5])
> >
> > This problem occurs when overlapping more than 1 char.
> > e.g. [[1, 1, 5], [1, 5, 5]] is no problem.
> >
> > [cause]
> >
> > https://github.com/vim/vim/blob/fd89d7e/src/screen.c#L7770-L7771
> >
> > On processing second pos [1, 3, 5], mincol is 5 (end of first pos col).
> > Thus, col (== 3) is less then mincol, and second pos is skipped.
> >
> > I think that the case of "col < mincol < col + len -1" should be also processed.
> >
> > [patch]
> >
> > https://gist.github.com/ichizok/f34c9018f5e9e452d3bc78cc9026a720
>
> Can you please add a test that fails without the patch?

Here is a test patch.
I confirmed pass the test with Kiichi's patch, and fails without it.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

matchaddpos_test.patch

Bram Moolenaar

unread,
Oct 15, 2016, 8:57:02 AM10/15/16
to h_east, vim_dev, gclien...@gmail.com
Thanks!

--
BRIDGEKEEPER: What is your favorite editor?
GAWAIN: Emacs ... No, Viiiiiiiiiiimmmmmmm!
"Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
Reply all
Reply to author
Forward
0 new messages