branch: elpa/lua-mode
commit 9d86a227d1072b801cb14358b92ead853757180d
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
Fix indentation error raised if 'else' is on the same line as 'if'
---
lua-mode.el | 4 ++--
test/test-indentation.el | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 487c4cc..ca6230b 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1284,14 +1284,14 @@ and the cdr of the replace-matching info is added in
its place. This is used
when a middle-of the block (the only case is 'else') is seen on the same line
the block is opened."
(cond
- ( (listp (cdr-safe pair))
- (nconc pair info))
( (eq 'remove-matching (car pair))
; Remove head of list
(cdr info))
( (eq 'replace-matching (car pair))
; remove head of list, and add the cdr of pair instead
(cons (cdr pair) (cdr info)))
+ ( (listp (cdr-safe pair))
+ (nconc pair info))
( t
; Just add the pair
(cons pair info))))
diff --git a/test/test-indentation.el b/test/test-indentation.el
index e9fec46..53810db 100644
--- a/test/test-indentation.el
+++ b/test/test-indentation.el
@@ -437,8 +437,12 @@ elseif baz then
a = a + 3
end
-a = 0"))
+a = 0")
+ (should-lua-indent "\
+if foo then a = a + 1 else
+ a = a + 2
+end"))
(ert-deftest lua-indentation-defun ()
;; [local] function funcname funcbody