Home Download Buy Blog Forum Support

Ruby { } blocks are broken

Ruby { } blocks are broken

Postby luislavena on Tue Apr 05, 2011 10:51 pm


Currently the Ruby package/snippets do not correctly support {+tab.

Hitting it, It produces the following output:

Code: Select all
{ variablevariablevariable }

Ideally, the output should be:

{ |variable| }

do block used to suffer from similar issue.

Tried to find where this is defined without avail.

Thank you.
Posts: 25
Joined: Fri Jun 04, 2010 7:15 pm

Re: Ruby { } blocks are broken

Postby jtpierce on Sun Apr 10, 2011 7:12 am

Confirming that the do ... end snippet works correctly and that this {+tab snippet results in 'variablevariablevariable' junk. It's in .Sublime Text 2/Packages/Ruby/open-yield-block*.sublime-snippet but I didn't test the regex.

On a similar note the Ruby package could use some updates to support 1.9 and JRuby conventions.. has anyone already undertaken this effort?
Posts: 2
Joined: Wed Feb 02, 2011 9:30 am

Re: Ruby { } blocks are broken

Postby meno on Mon Oct 10, 2011 3:49 pm

any news on this issue? or a viable workaround?
Posts: 9
Joined: Thu Mar 03, 2011 7:27 am

Re: Ruby { } blocks are broken

Postby swerdna on Thu Dec 08, 2011 1:35 pm

Yes, I found this annoying too.

I did a quick fix by replacing the contents of Sublime Text 2/Packages/Ruby/open-yield-block-({).sublime-snippet with:
Code: Select all
    <content><![CDATA[{${1/(^.+$)|^$/(?1: |)/}${1:variable}${1/(^.+$)|^$/(?1:|)/} $0 ]]></content>
    <description>Insert { |variable| … }</description>

(You may wish to comment out the original contents and add the above, so you can easily revert it).

The original <content> tag expression was attempting to take your context (writing ruby, inside a string or in a comment) into account, but as I tend not to hit {[tab] inside strings or comments I wasn't so worried about those two scenarios. I haven't had time to investigate how to fix it directly (and the regex is challenging), so what you see is adapted from the mechanism in the do-obj-..-end-(doo).sublime-snippet.

The result generates the expected { |variable| } and supports tabbing from the variable to writing an expression. It works for me, but hasn't been widely tested.
Posts: 2
Joined: Wed Sep 28, 2011 7:13 pm
Location: UK

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 16 guests