Browse files

Indent failed in catch with guards

  • Loading branch information...
1 parent 3a2a8c6 commit 785679e74f7f5fc3c99e9a10c7af9500f98fe74b @jakobc jakobc committed Feb 19, 2013
View
30 org.erlide.kernel.ide/src/parsing/erlide_indent.erl
@@ -878,24 +878,30 @@ i_catch_clause(R0, I0) ->
var -> i_kind(var, R1, I0)
end,
?D(R2),
- R3 = i_kind(':', R2, I0),
- ?D(R3),
- {R4, _A} = i_expr(R3, I0, none),
- ?D(R4),
+ R3 = case i_sniff(R2) of
+ ':' ->
+ R21 = i_kind(':', R2, I0),
+ ?D(R21),
+ {R22, _A} = i_expr(R21, I0, none),
+ ?D(R22),
+ R22;
+ _ ->
+ R2
+ end,
I1 = i_with(before_arrow, R1, I0),
- R5 = case i_sniff(R4) of
+ R4 = case i_sniff(R3) of
'when' ->
- R41 = i_kind('when', R4, I1),
- {R42, _A} = i_predicate_list(R41, I1),
- R42;
+ R31 = i_kind('when', R3, I1),
+ {R32, _A0} = i_predicate_list(R31, I1),
+ R32;
_ ->
- R4
+ R3
end,
+ ?D(R4),
+ R5 = i_kind('->', R4, I1),
?D(R5),
- R6 = i_kind('->', R5, I1),
- ?D(R6),
I2 = i_with(clause, R1, I0),
- R = i_expr_list(R6, I2),
+ R = i_expr_list(R5, I2),
R.
i_catch_clause_list(R, I) ->
View
20 org.erlide.kernel.tests/src/erlide_indent_tests.erl
@@ -221,6 +221,26 @@ indent_spec_with_when_test_() ->
" ok.\n",
?Test_indent(I, S).
+%% http://assembla.com/spaces/erlide/tickets/1151-indent--fails-for-catch-with-guards
+indent_catch_with_guards_test_() ->
+ S = "" ++
+ "f() ->\n"++
+ "try\n"++
+ "a\n"++
+ "catch\n"++
+ "A when is_tuple(A) ->\n"++
+ "A\n"++
+ "end.\n",
+ I = "" ++
+ "f() ->\n"++
+ " try\n"++
+ " a\n"++
+ " catch\n"++
+ " A when is_tuple(A) ->\n"++
+ " A\n"++
+ " end.\n",
+ ?Test_indent(I, S).
+
%%
%% Local Functions
%%

0 comments on commit 785679e

Please sign in to comment.