Am 13.05.2011 19:24, schrieb Radoslaw Nadstawny:
Hi there,
I've encountered some weird behavior in syntax highlighting that happens
when I use the 'extend' attribute. It's hard to describe precisely
with words, so I'm attaching an example to illustrate it.

I've tried to look into the code to find the source of this behavior,
but eventually decided that trying to understand what it does would
take me too much time so I gave up.

" test.vim
sy clear
sy region  braces  matchgroup=Preproc  start=/{/  end=/}/  contains=TOP  keepend
sy region  parens  matchgroup=Operator  start=/(/  end=/)/  contains=TOP  extend
sy region  brackets  matchgroup=Todo  start=/\[/  end=/]/  transparent  extend
sy match  angles  /<.\{-}>/  contains=TOP
hi link  braces  String
hi link  parens  Statement
hi link  angles  Special

test.txt
This highlights correctly:
  (a[a(a)a]a)
  {a(a[a]a)a}
    <a[a]a>

But try this:
{a(a[a(a)a]a)a}
           ^^

You have a nested match for "parens", but no "keepend" to be "extend"-ed.

What works for me is to either remove "extend", or add "keepend" in the
parens rule:

    :sy region  parens  matchgroup=Operator  start=/(/  end=/)/  contains=TOP
    " or
    :sy region  parens  matchgroup=Operator  start=/(/  end=/)/  contains=TOP  
extend  keepend

  <a[a<a>a]a>
           ^^

The "angles" rule (with pattern "<.\{-}>") matches "<a[a<a>", I don't
think the contained "[a<a>a]" should make it match "<a[a<a>a]a>".

  {a<a[a]a>a}
         ^^
What happened?

You use "extend" where it's not needed, apparently Vim doesn't like that.

--
Andy

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

Raspunde prin e-mail lui