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

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.










Skade said
I experience similar problems. I will dive into this.
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.).
Skade said
I reported this problem:
http://www.nabble.com/Ruby-Bundle%2C-%22Run%22-Command%2C-glitch-tf4791054.html