Ph values

Stephan on Ruby, testing, software (good and bad) 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 Says:

    I experience similar problems. I will dive into this.

  2. Skade Says:

    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 Says:

    I reported this problem:

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

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>