Textmate's Ruby grammar appears to get confused by the
foo = { "bar" => 42 }
but adding a comment after the closing brace throws things off:
foo = { "bar" => 42 } # comment breaks indentation
I tend to use "Indent Line" (⌥⌘[) quite a bit, and this behaviour makes it pretty hard to easily re-indent nested data structures, e.g.
data = { "jim" => { "name" => "James Jameson" }, "bob" => { "name" => "Robert Robertson" }, "billy" => { "name" => "William Williams" } }
The problem seems to be limited to Ruby mode; other language grammars (e.g. Java, Javascript) seem to be unaffacted.
Am I the only one experiencing this? Any bright ideas?
Am I the only one experiencing this? Any bright ideas?
Yes, there's little bug in Ruby indention settings, that does not take comment into consideration, go to: Edit Bundles… > Ruby > Settings > Indent and update:
decreaseIndentPattern = '^\s*([}]]\s*(#|$)|(end|rescue|ensure|else|elsif|when)\b)';
Cheers,
On 04/01/2012, at 4:03 AM, Adam Strzelecki wrote:
Yes, there's little bug in Ruby indention settings, that does not take comment into consideration, go to: Edit Bundles… > Ruby > Settings > Indent and update:
decreaseIndentPattern = '^\s*([}]]\s*(#|$)|(end|rescue|ensure|else|elsif|when)\b)';
Thanks Adam! That almost did the trick. I actually changed it to:
^\s*([}]]|(end|rescue|ensure|else|elsif|when)\b)
so that anything after the close-brace is ignored. Otherwise, the nested-hash example indents badly (due to a comma after the close-brace).
On Jan 3, 2012, at 11:03 AM, Adam Strzelecki wrote:
Yes, there's little bug in Ruby indention settings, that does not take comment into consideration, go to: Edit Bundles… > Ruby > Settings > Indent and update:
decreaseIndentPattern = '^\s*([}]]\s*(#|$)|(end|rescue|ensure|else|elsif|when)\b)';
Thanks for the patch, just committed this change as well as supporting nested hashes.