Ph values

Stephan on testing, software (good and bad), Ruby and the world at large

TextMate, Ruby & String Interpolation

Posted by Stephan on 7. November 2007

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 #{ … }.

cursor_outside_srint_interpol.png

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

outside_result.png

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

cursor_inside_print_interpol.png

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


inside_result.png

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 Responses to “TextMate, Ruby & String Interpolation”

  1. Skade said

    I experience similar problems. I will dive into this.

  2. Skade said

    Okay, here is a quick fix:

    The scope of #{…} is:
    source.ruby.embedded.source

    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.).

  3. Skade said

    I reported this problem:

    http://www.nabble.com/Ruby-Bundle%2C-%22Run%22-Command%2C-glitch-tf4791054.html

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 )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.