Skip to content

Commit 77b2a94

Browse files
committed
Add correct indent for "if" inside a "->" block
1 parent 4198d1e commit 77b2a94

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

elixir-smie.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,17 @@
455455
(t elixir-smie-indent-basic)))
456456
(`(:before . "if")
457457
(cond
458+
;; Indent when if is inside a `->' block
459+
;;
460+
;; Example:
461+
;;
462+
;; whatever ->
463+
;; if true do <-
464+
;; :foo
465+
;; end
466+
;; ....
467+
((elixir-smie-last-line-end-with-block-operator-p)
468+
(smie-rule-parent elixir-smie-indent-basic))
458469
(t
459470
(smie-rule-parent))))
460471
(`(:before . "->")

test/elixir-mode-indentation-test.el

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,37 @@ defmodule MyModule do
13331333
end
13341334
")
13351335

1336+
(elixir-def-indentation-test complex-case-with-matches/4
1337+
(:tags '(indentation))
1338+
"
1339+
case :foo do
1340+
1 ->
1341+
try true do
1342+
:foo
1343+
end
1344+
2 ->
1345+
false
1346+
end
1347+
1348+
fn x ->
1349+
if true do
1350+
end
1351+
end"
1352+
"
1353+
case :foo do
1354+
1 ->
1355+
try true do
1356+
:foo
1357+
end
1358+
2 ->
1359+
false
1360+
end
1361+
1362+
fn x ->
1363+
if true do
1364+
end
1365+
end")
1366+
13361367
(elixir-def-indentation-test close-map-curly-brackt
13371368
(:tags '(indentation))
13381369
"

0 commit comments

Comments
 (0)