Sublime Forum

Ruby package issues with 'do' snippet

#1

Hello,

Using Sublime 1.4 had issues with Ruby package when pressing ‘do’ and then tab for autocomplete.

The output I received was:

dovariablevariablevariable end

I expected to see:

do |variable| end

Instead.

Took a quick look to the snippet and couldn’t figure out the regexp to fix it.

Thank you :smile:

0 Likes

#2

The snippet is doing some funky things with named expressions, below is a simpler version that will work properly with Sublime Text’s regex engine. Let me know if this works for you, and I’ll include it by default.

<snippet>
    <content><![CDATA[do${1/(^.+$)|^$/(?1: |)/}${1:variable}${1/(^.+$)|^$/(?1:|)/}
	$0
end]]></content>
    <tabTrigger>do</tabTrigger>
    <scope>source.ruby</scope>
    <description>Insert do |variable| … end</description>
</snippet>
0 Likes

#3

Awesome, thank you.

It did the trick.

0 Likes