Groovy-Emacs-Modes / groovy-emacs-modes

A groovy major mode, grails minor mode, and a groovy inferior mode.
84 stars 39 forks source link

Ensure we indent switch statements correctly #60

Closed Wilfred closed 7 years ago

Wilfred commented 7 years ago

Fixes #40.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+12.4%) to 58.654% when pulling 55d337f124aa0b38d0b92e84fc1b41b6012f38bf on indent_switch into 847c3914589f312917b3b9b616e55ec07069a98c on master.

russel commented 7 years ago

Does this cover the case where people do "x? y: z" or "case X :" or is it assuming a specific use of space?

Wilfred commented 7 years ago

case x : should work because we just look for a line ending with : inside a switch block.

x? y: z should also work because the line doesn't end with :.

I agree that logic like this is tricky though. I believe the logic here works in the large majority of cases (though as it's line oriented, it may be possible to get incorrect indentation on large multiline expressions) but I think it's a worthwhile improvement over the current state of the code.

russel commented 7 years ago

I think I am in "irritated" mode, so apologies, but do you think we should put tests in for these cases?

Wilfred commented 7 years ago

@russel added more tests, and fixed the issues they exposed :)

coveralls commented 7 years ago

Coverage Status

Coverage increased (+13.2%) to 59.434% when pulling 439fb7cf864bc67344a045d83ea6e44918cf9703 on indent_switch into 847c3914589f312917b3b9b616e55ec07069a98c on master.