如何配置 RubyMine 在转换代码时保留 Ruby 1.9.2 哈希语法?
RubyMine 可以在 do;end
和 { }
块表示法之间切换块语法。例如,给定以下代码:
[1, 2, 3].each do |i|
puts i
end
我可以将插入符号放在 do
处,然后按 Option-Enter Enter(在 Mac 上)将此代码片段转换为:
[1, 2, 3].each { |i| puts i }
对 处的插入符号执行相同的操作>{
执行逆变换。
然而,当块内的代码包含 Ruby 1.9.2 的新哈希语法时,RubyMine 在转换过程中会破坏它:
# before
[1, 2, 3].each { |i| some_func(param: i) }
# after
[1, 2, 3].each do |i|
some_func(param : i)
end
注意 param
和 :
之间的空格。
我查看了 RubyMine 首选项中的 Ruby 样式选项,但找不到任何控制冒号的内容。如何防止 RubyMine 弄乱我的冒号?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是一个错误,我已将其提交给 RubyMine 问题跟踪器,请随时 watch/投票。
It appears to be a bug, I've submitted it to the RubyMine issue tracker, feel free to watch/vote.