Thursday, June 2, 2011

Re: syntax highlighting: 'good' syntax item becomes 'bad' after unrelated change in file

> I'm experiencing a problem where a valid piece of syntax (a variable
> declaration) sudden;y changes state (becomes an (invalid) procedure
> call) following the insertion elsewhere in the file of an indexed
> assignment.
[...]
> Here is a simple test file that shows the problem, which shows that
> the problem exhibits itself even when the assignment that provokes the
> error is inside a comment.

This indeed seems very strange. With sync fromstart, I can't imagine why
this would happen, particularly in the case where it's in a comment, as
it's a completely irrelevant syntax item.

Maybe it's a bug in Vim's syntax engine. We seem to have been finding a
few of those recently.

> 1. sclProcedureCall is declared earlier in the syntax file than
> sclStringDeclaration.

Does that matter? Did you try swapping them? If it doesn't matter,
probably not worth mentioning!

> 2. I use 'foldmethod=syntax' and use folding aggressively to detect
> bad syntax.

I don't think this is relevant either. With foldmethod=manual the
problem still occurs.

> 3. sclStringDeclaration is a region with 'start=/\ze\<string\>/
> skip=/\(\<string\|)\},\)\_s*/ end=/,/ end=/$/'

Seems a bit different to that in the actual syntax file. The one in the
syntax file seems a bit more sensible, though.

> 4. The reason for the \ze in the 'start' pattern is to make the folds
> work for declarations and assignments.

OK. That is helpful to know.

> 5. An indexed assignment is modelled as a procedure call - it has the
> same semantics as a procedure call returning a reference has.

OK.

> Can anyone suggest what might be causing this problem?

Not yet. Your minimal test data was wonderful, though I've managed to
minimise it even more. This is enough to show the problem:

string ( 80 ) message := ""
@ )=

In fact, the problem is easier to see there, because Vim seems to update
more quickly as you edit. Modifying the comment causes the highlighting
to change 'in realtime'.

I'm still a bit baffled.

Perhaps work on this even smaller example and see if you can minimise
the syntax file. This example doesn't require a procedure body or
anything like that, so should be able to work with a really small syntax
file, and that should help us pinpoint either the problem with the
syntax file or the bug in Vim.

Cheers,

Ben.

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

No comments:

Post a Comment