csharp-tmLanguage icon indicating copy to clipboard operation
csharp-tmLanguage copied to clipboard

csharp.tmLanguage: invalid pattern in look-behind

Open sebthom opened this issue 1 year ago • 2 comments

Details

What editor are you seeing the problem in? (e.g. Atom, Visual Studio Code, etc.) Ruby, Eclipse TM4E

What version of the editor are you using? 0.9

What color theme are you using? Solarized

Repro

TextMate uses the oniguruma syntax for regular expressions.

The await-statement pattern at https://github.com/dotnet/csharp-tmLanguage/blob/7a7482ffc72a6677a87eb1ed76005593a4f7f131/grammars/csharp.tmLanguage#L2939-L2942 however is not parsable using the oniguruma regex library and results in invalid pattern in look-behind.

you can try it here https://onecompiler.com/ruby/422uzf35h Ruby uses the oniguruma library for regex parsing.

sebthom avatar Jan 29 '24 11:01 sebthom

I think the issue is the usage of variable-length negative look-behind.

It might be easily solvable by changing:

from: /(?<!\.\s*)\b(await)\b/
  to: /(?<!\.)\s*\b(await)\b/

i.e.

from: <string>(?&lt;!\.\s*)\b(await)\b</string> 
  to: <string>(?&lt;!\.)\s*\b(await)\b</string> 

sebthom avatar Jan 30 '24 13:01 sebthom

Ruby, Eclipse TM4E must be using an outdated version of oniguruma as the current version of oniguruma does support variable length lookbehinds

RedCMD avatar Apr 12 '24 21:04 RedCMD

Yeah we are using the implementation from JRuby which apparently lags behind. Thanks for your pointer.

sebthom avatar May 16 '24 20:05 sebthom