Search code examples
rubyrubymine

How to configure RubyMine to preserve Ruby 1.9.2 hash syntax when transforming code?


RubyMine can toggle block syntax between do;end and { } block notation. For example, given the following code:

[1, 2, 3].each do |i|
  puts i
end

I can place the caret at do and press Option-Enter Enter (on the Mac) to convert this code snippet to:

[1, 2, 3].each { |i| puts i }

Doing the same with the caret at the { performs the reverse transformation.

However when the code inside the block contains Ruby 1.9.2's new hash syntax, RubyMine destroys it during the transformation:

# before
[1, 2, 3].each { |i| some_func(param: i) }

# after
[1, 2, 3].each do |i|
  some_func(param : i)
end

Note the space between param and the :.

I looked through the Ruby style options in RubyMine's preferences but wasn't able to find anything which controls colons. How can I prevent RubyMine from messing around with my colons?


Solution

  • It appears to be a bug, I've submitted it to the RubyMine issue tracker, feel free to watch/vote.