From morita-pub-en at inz.sakura.ne.jp Fri Sep 11 16:17:18 2009 From: morita-pub-en at inz.sakura.ne.jp (Morita Sho) Date: Sat, 12 Sep 2009 05:17:18 +0900 Subject: Some regexp pattern breaks the syntax highlighting. Message-ID: <4AAAB04E.10905@inz.sakura.ne.jp> 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 From morita-pub-en at inz.sakura.ne.jp Fri Sep 11 23:37:52 2009 From: morita-pub-en at inz.sakura.ne.jp (Morita Sho) Date: Sat, 12 Sep 2009 12:37:52 +0900 Subject: Some regexp pattern breaks the syntax highlighting. In-Reply-To: <4AAAB04E.10905@inz.sakura.ne.jp> References: <4AAAB04E.10905@inz.sakura.ne.jp> Message-ID: <4AAB1790.1040001@inz.sakura.ne.jp> 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 From vim-ruby-devel at tpope.info Fri Sep 11 23:46:33 2009 From: vim-ruby-devel at tpope.info (Tim Pope) Date: Fri, 11 Sep 2009 23:46:33 -0400 Subject: Some regexp pattern breaks the syntax highlighting. In-Reply-To: <4AAB1790.1040001@inz.sakura.ne.jp> References: <4AAAB04E.10905@inz.sakura.ne.jp> <4AAB1790.1040001@inz.sakura.ne.jp> Message-ID: <20090912034633.GU31192@maeby.tpope.net> 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 From dougkearns at gmail.com Sat Sep 12 06:09:06 2009 From: dougkearns at gmail.com (Doug Kearns) Date: Sat, 12 Sep 2009 20:09:06 +1000 Subject: Some regexp pattern breaks the syntax highlighting. In-Reply-To: <20090912034633.GU31192@maeby.tpope.net> References: <4AAAB04E.10905@inz.sakura.ne.jp> <4AAB1790.1040001@inz.sakura.ne.jp> <20090912034633.GU31192@maeby.tpope.net> Message-ID: <644fc65e0909120309k48175bc2te83a6075436a9d94@mail.gmail.com> On Sat, Sep 12, 2009 at 1:46 PM, Tim Pope 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