Skip to content

Commit 2368280

Browse files
committed
Merge pull request #190 from elixir-lang/issue-184
correct indentation for multiclause anonymous functions
2 parents 5aac3d3 + c752210 commit 2368280

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

elixir-smie.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,10 @@
291291
(smie-rule-parent))
292292
;; Closing paren on the other line
293293
(`(:before . "(")
294-
(smie-rule-parent))
294+
(cond
295+
((smie-rule-parent-p "fn")
296+
(smie-rule-parent elixir-smie-indent-basic))
297+
(t (smie-rule-parent))))
295298
(`(:before . "[")
296299
(cond
297300
((smie-rule-hanging-p)

test/elixir-mode-indentation-test.el

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,6 @@ def foo(test) do
965965
run(test_case)
966966
end")
967967

968-
;; Will pass when #180 is resolved.
969968
(elixir-def-indentation-test indent-after-bitstring/1
970969
(:tags '(indentation))
971970
"
@@ -981,6 +980,29 @@ defmodule X do
981980
def c, do: <<3 :: size(8)>>
982981
end")
983982

983+
(elixir-def-indentation-test indent-after-fn/1
984+
(:tags '(indentation))
985+
"
986+
defmodule X do
987+
def func do
988+
Enum.filter([1,2,3],
989+
fn(1) -> true
990+
(2) -> false
991+
(_) -> true
992+
end)
993+
end
994+
end"
995+
"
996+
defmodule X do
997+
def func do
998+
Enum.filter([1,2,3],
999+
fn(1) -> true
1000+
(2) -> false
1001+
(_) -> true
1002+
end)
1003+
end
1004+
end")
1005+
9841006
;; We don't want automatic whitespace cleanup here because of the significant
9851007
;; whitespace after `Record' above. By setting `whitespace-action' to nil,
9861008
;; `whitespace-mode' won't automatically clean up trailing whitespace (in my

0 commit comments

Comments
 (0)