Some regexp pattern breaks the syntax highlighting.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Some regexp pattern breaks the syntax highlighting.

Morita Sho-3
Hi,

Some regexp pattern breaks the syntax highlighting.


How to reproduce the problem:

First of all, create a ruby script as following and open it with Vim.

% cat test.rb
func /\(/
puts

At this point, the script will be highlighted correctly.
Then, hit Ctrl-E to scroll down the window (the line "func /\(/" goes
out of the screen), and hit Ctrl-L to redraw. After redrawing the window,
the line "puts" will be highlighted wrongly as a regexp literal.

It seems that the highlighting works if the line "func /\(/" is visible,
but won't work if the line "func /\(/" is out of the screen.

I tested latest syntax/ruby.vim pulled from git repository, but it doesn't
solve the problem.


Thanks,
--
Morita Sho <[hidden email]>


_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Some regexp pattern breaks the syntax highlighting.

Morita Sho-3
Some updates:

After some investigations, I suspect that the following line in
syntax/ruby.rb is problematic.

  syn match  rubyRegexpEscape  "\\[].*?+^$|\\/(){}[]"  contained display

As far as I understand it, this matches a regexp escape character. I think the problem is
the "display" keyword. According to Vim manual:

 display *:syn-display*

 If the "display" argument is given, this item will be skipped when the
 detected highlighting will not be displayed.  This will speed up highlighting,
 by skipping this item when only finding the syntax state for the text that is
 to be displayed.

As result, the regexp pattern \( will not be interpreted as an escaped character
if that pattern will not be displayed. Removing the "display" keyword for
rubyRegexpEscape solves the problem for me.

Thanks,
--
Morita Sho <[hidden email]>
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Some regexp pattern breaks the syntax highlighting.

Tim Pope-2
On Sat, Sep 12, 2009 at 12:37:52PM +0900, Morita Sho wrote:
> As result, the regexp pattern \( will not be interpreted as an escaped character
> if that pattern will not be displayed. Removing the "display" keyword for
> rubyRegexpEscape solves the problem for me.

Nice detective work.  I've pushed up your fix.

Cheers,
Tim
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Some regexp pattern breaks the syntax highlighting.

Doug Kearns
On Sat, Sep 12, 2009 at 1:46 PM, Tim Pope <[hidden email]> wrote:
> On Sat, Sep 12, 2009 at 12:37:52PM +0900, Morita Sho wrote:
>> As result, the regexp pattern \( will not be interpreted as an escaped character
>> if that pattern will not be displayed. Removing the "display" keyword for
>> rubyRegexpEscape solves the problem for me.
>
> Nice detective work.

+1 Our favourite kind of user. :)

Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Loading...