TextMate, Ruby & String Interpolation

While preparing some code example for the Euruko 2007 I noticed a somewhat strange behaviour of TextMate while editing Ruby code. With the Ruby bundle being active, I expect CMD-R (“Apple-R”) to execute the Ruby code a hand. Which it does, unless the text cursor is inside a string interpolation expression.

An example: The first screen shot shows the example code, the cursor being positioned outside the #{ … }.


After CMD-R is hit, the output is the expected Ruby output as shown below.


However, if the cursor is inside the string interpolation expression as below


the result of hitting CMD-R doesn’t meet my expectation:


I wonder why this happens. Apparently the behaviour has to do the the scope the cursor is in. A hint about how to avoid this is greatly appreciated.


3 thoughts on “TextMate, Ruby & String Interpolation

  1. Okay, here is a quick fix:

    The scope of #{…} is:

    The scope selector for Run is:

    source.ruby – source.ruby.embedded

    (on every ruby-source that is not embedded)

    If you delete “- source.ruby.embedded”, this works well. The problem is: now you have this command vor every embedded source (ERB, etc.).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s