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
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)