branch: elpa/lua-mode
commit 1365ba0df92d33adafb8a3ce8fb1784087380826
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
Enable XFAIL-ing tests for continuation in block intros
---
lua-mode.el | 25 ++++++++++++--------
test/indentation-tests/continuation-lines.lua | 19 +--------------
test/indentation-tests/for-equals-block.lua | 26 +++++++++++++++------
test/indentation-tests/for-in-block.lua | 33 ++++++++++++++++++++-------
4 files changed, 60 insertions(+), 43 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index ef86c98..0f45136 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1354,16 +1354,21 @@ The criteria for a continuing statement are:
(let (prev-line return-value)
(save-excursion (setq prev-line (lua-forward-line-skip-blanks 'back)))
(and prev-line
- ;; Binary operator or keyword that implies continuation.
- (and (setq return-value
- (or (lua-first-token-continues-p)
- (save-excursion (and (goto-char prev-line)
- ;; check last token of previous
nonblank line
- (lua-last-token-continues-p)))))
- (not (member (car-safe (lua--backward-up-list-noerror))
- ;; XXX: can we also add "{" here?
- '("(" "[")))
- return-value))))
+ (or
+ ;; Binary operator or keyword that implies continuation.
+ (and (setq return-value
+ (or (lua-first-token-continues-p)
+ (save-excursion (and (goto-char prev-line)
+ ;; check last token of previous
nonblank line
+ (lua-last-token-continues-p)))))
+ (not (member (car-safe (lua--backward-up-list-noerror))
+ ;; XXX: can we also add "{" here?
+ '("(" "[")))
+ return-value)
+ ;; "for" expressions (until the next do) imply continuation.
+ (when (string-equal (car-safe (lua--backward-up-list-noerror)) "for")
+ (point))))))
+
(defun lua-is-continuing-statement-p (&optional parse-start)
diff --git a/test/indentation-tests/continuation-lines.lua
b/test/indentation-tests/continuation-lines.lua
index 63ac9fb..018c27b 100644
--- a/test/indentation-tests/continuation-lines.lua
+++ b/test/indentation-tests/continuation-lines.lua
@@ -134,7 +134,7 @@ x = [
+ another_very_very_very_long_name()
]
--- XFAIL: indentation in block-intros: while
+-- indentation in block-intros: while
while
foo do
@@ -153,23 +153,6 @@ end
a = 0
--- XFAIL: indentation in block-intros: for1
-
-for k, v
- in pairs(bar) do
- a = a + 1
-end
-
-a = 0
-
--- XFAIL: indentation in block-intros: for2
-
-for k, v
- in pairs(bar) do a = a + 1 end
-
-a = 0
-
-
-- indents expressions after return: basic
function myfunc()
diff --git a/test/indentation-tests/for-equals-block.lua
b/test/indentation-tests/for-equals-block.lua
index c3bc0b7..6609560 100644
--- a/test/indentation-tests/for-equals-block.lua
+++ b/test/indentation-tests/for-equals-block.lua
@@ -1,11 +1,11 @@
--- works for for ... = ... do block: 1
+-- works for "for ... = ... do" block: 1
for y = 0, 10 do
a = a + 1
end
a = 0
--- works for for ... = ... do block: 2
+-- works for "for ... = ... do" block: 2
for y = 0, 10
do
a = a + 1
@@ -13,7 +13,7 @@ end
a = 0
--- XFAIL: works for for ... = ... do block: 3
+-- works for "for ... = ... do" block: 3
for y = 0,
10 do
a = a + 1
@@ -21,7 +21,7 @@ end
a = 0
--- XFAIL: works for for ... = ... do block: 4
+-- works for "for ... = ... do" block: 4
for y = 0,
10
do
@@ -30,7 +30,7 @@ end
a = 0
--- works for for ... = ... do block: 5
+-- works for "for ... = ... do" block: 5
for y =
0, 10 do
a = a + 1
@@ -38,7 +38,7 @@ end
a = 0
--- works for for ... = ... do block: 6
+-- works for "for ... = ... do" block: 6
for y =
0, 10
do
@@ -47,7 +47,19 @@ end
a = 0
--- works for for ... = ... do block: single line
+-- works for "for ... = ... do" block: 7
+for y = foo(
+ 1,
+ 2),
+ bar(3,
+ 4)
+do
+ a = a + 1
+end
+
+a = 0
+
+-- works for "for ... = ... do" block: single line
for y = 0, 10 do a = a + 1 end
diff --git a/test/indentation-tests/for-in-block.lua
b/test/indentation-tests/for-in-block.lua
index 5d10dd0..c615dce 100644
--- a/test/indentation-tests/for-in-block.lua
+++ b/test/indentation-tests/for-in-block.lua
@@ -1,4 +1,4 @@
--- works for for ... do block: 1
+-- works for "for .. in .. do" block: 1
for k, v in pairs(bar) do
a = a + 1
@@ -6,7 +6,7 @@ end
a = 0
--- works for for ... do block: 2
+-- works for "for .. in .. do" block: 2
for
k, v in pairs(bar) do
@@ -15,7 +15,7 @@ end
a = 0
--- XFAIL: works for for ... do block: 3
+-- works for "for .. in .. do" block: 3
for
k,
@@ -25,7 +25,7 @@ end
a = 0
--- XFAIL: works for for ... do block: 4
+-- works for "for .. in .. do" block: 4
for
k,
@@ -36,7 +36,7 @@ end
a = 0
--- works for for ... do block: 5
+-- works for "for .. in .. do" block: 5
for k, v in
pairs(bar) do
@@ -45,7 +45,7 @@ end
a = 0
--- works for for ... do block: 6
+-- works for "for .. in .. do" block: 6
for k, v in
pairs(bar)
@@ -55,7 +55,24 @@ end
a = 0
--- works for for ... do block: 7
+-- works for "for .. in .. do" block: 7
+
+for k, v
+ in pairs(bar) do
+ a = a + 1
+end
+
+a = 0
+
+-- works for "for .. in .. do" block: 8
+
+for k, v
+ in pairs(bar) do a = a + 1 end
+
+a = 0
+
+
+-- works for "for .. in .. do" block: 9
for k, v in pairs(bar)
do
a = a + 1
@@ -63,7 +80,7 @@ end
a = 0
--- works for for ... do block: single line
+-- works for "for .. in .. do" block: single line
for k, v in pairs(bar) do a = a + 1 end
a = 0