Monday, August 11, 2014

Re: vim-7.4.389 UI extremely sluggish with custom syntax highlighting plugins

Christian Brabandt wrote:

> On Sa, 09 Aug 2014, Bram Moolenaar wrote:
>
> >
> > David Barnett wrote:
> >
> > > Looks like it's patch 7.4.362:
> > >
> > > Problem: When matchaddpos() uses a length smaller than the number of
> > > bytes
> > > in the (last) character the highlight continues until the end of
> > > the line.
> > > Solution: Change condition from equal to larger-or-equal.
> > > Files: src/screen.c
> > >
> > >
> > > It's a very small change but apparently problematic. Can it be reverted or
> > > rethought?
> >
> > I'm glad you could pinpoint it. I assumed that when the condition
> > evaluates to true the match information would be updated. But perhaps
> > that doesn't happen in this case and it searches for a match every time.
> >
> > Needs some debugging to figure out what happens. What matches does this
> > plugin add when it's slow?
>
> Perhaps it is better to revert that patch and make sure, highlighting
> gets only applied, if there is a match at the actual position?
>
> diff --git a/src/screen.c b/src/screen.c
> --- a/src/screen.c
> +++ b/src/screen.c
> @@ -3852,7 +3852,7 @@ win_line(wp, lnum, startrow, endrow, noc
> {
> shl->attr_cur = shl->attr;
> }
> - else if (v >= (long)shl->endcol)
> + else if (v == (long)shl->endcol)
> {
> shl->attr_cur = 0;
> next_search_hl(wp, shl, lnum, (colnr_T)v, cur);
> @@ -3913,7 +3913,10 @@ win_line(wp, lnum, startrow, endrow, noc
> }
> else
> shl = &cur->hl;
> - if (shl->attr_cur != 0)
> + /* make sure, match is actually at the current position */
> + if (shl->attr_cur != 0
> + && v >= (long)shl->startcol
> + && v < (long)shl->endcol)
> search_attr = shl->attr_cur;
> if (shl != &search_hl && cur != NULL)
> cur = cur->next;

I haven't tried it, but it looks like this only avoids highlighting
positions after the endcol when "v" and shl->endcol aren't exactly the
same (which can happen for multi-byte characters), but it doesn't update
the state, thus a next match might be missed.

--
hundred-and-one symptoms of being an internet addict:
27. You refer to your age as 3.x.

/// Bram Moolenaar -- Bram@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 ///

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