branch: elpa/lua-mode
commit dc55356ca2464f7712a9d3ca77c81da49f39ce48
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
lua-forward-regexp: make sure direction is `forward'
For middle tokens (then/else/elseif) default direction is backward.
---
lua-mode.el | 7 ++++---
test/generic-test.el | 8 ++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 6ff8798..3405c4a 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1801,19 +1801,20 @@ left out."
(defun lua-forward-sexp (&optional count)
"Forward to block end"
(interactive "p")
+ ;; negative offsets not supported
+ (assert (or (not count) (>= count 0)))
(save-match-data
(let* ((count (or count 1))
(block-start (mapcar 'car lua-sexp-alist))
(block-end (mapcar 'cdr lua-sexp-alist))
(block-regex (regexp-opt (append block-start block-end) 'words))
- current-exp
- )
+ current-exp)
(while (> count 0)
;; skip whitespace
(skip-chars-forward " \t\n")
(if (looking-at (regexp-opt block-start 'words))
(let ((keyword (match-string 1)))
- (lua-find-matching-token-word keyword nil))
+ (lua-find-matching-token-word keyword 'forward))
;; If the current keyword is not a "begin" keyword, then just
;; perform the normal forward-sexp.
(forward-sexp 1))
diff --git a/test/generic-test.el b/test/generic-test.el
index 148e1a0..0090674 100644
--- a/test/generic-test.el
+++ b/test/generic-test.el
@@ -11,3 +11,11 @@
(lua-forward-sexp)
(should (looking-back "x = function() return {{}} end"))))
+(ert-deftest lua-forward-sexp-if-then-block ()
+ (with-lua-buffer
+ (lua-insert-goto-<>
+ '("if foo <>then"
+ " return bar"
+ "--[[end here]] end"))
+ (lua-forward-sexp)
+ (should (looking-back (rx "--[[end here]] end")))))