[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e52287c: Fix indentation error in js.el
From: |
Tom Tromey |
Subject: |
[Emacs-diffs] master e52287c: Fix indentation error in js.el |
Date: |
Fri, 24 Feb 2017 22:35:21 -0500 (EST) |
branch: master
commit e52287ca3e974ed9f658315288060f638081abb0
Author: Tom Tromey <address@hidden>
Commit: Tom Tromey <address@hidden>
Fix indentation error in js.el
* lisp/progmodes/js.el (js--indent-in-array-comp): Wrap forward-sexp
call in condition-case.
* test/lisp/progmodes/js-tests.el (js-mode-indentation-error): New
test.
---
lisp/progmodes/js.el | 15 ++++++++++-----
test/lisp/progmodes/js-tests.el | 10 ++++++++++
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 6e313dc..65325a8 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1986,11 +1986,16 @@ In particular, return the buffer position of the first
`for' kwd."
(js--forward-syntactic-ws)
(if (looking-at "[[{]")
(let (forward-sexp-function) ; Use Lisp version.
- (forward-sexp) ; Skip destructuring form.
- (js--forward-syntactic-ws)
- (if (and (/= (char-after) ?,) ; Regular array.
- (looking-at "for"))
- (match-beginning 0)))
+ (condition-case nil
+ (progn
+ (forward-sexp) ; Skip destructuring form.
+ (js--forward-syntactic-ws)
+ (if (and (/= (char-after) ?,) ; Regular array.
+ (looking-at "for"))
+ (match-beginning 0)))
+ (scan-error
+ ;; Nothing to do here.
+ nil)))
;; To skip arbitrary expressions we need the parser,
;; so we'll just guess at it.
(if (and (> end (point)) ; Not empty literal.
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el
index 99f5898..07e659a 100644
--- a/test/lisp/progmodes/js-tests.el
+++ b/test/lisp/progmodes/js-tests.el
@@ -118,6 +118,16 @@ if (!/[ (:,='\"]/.test(value)) {
;; implementation not recognizing the comment example.
(should-not (syntax-ppss-context (syntax-ppss))))))
+(ert-deftest js-mode-indentation-error ()
+ (with-temp-buffer
+ (js-mode)
+ ;; The bug previously was that requesting re-indentation on the
+ ;; "{" line here threw an exception.
+ (insert "const TESTS = [\n{")
+ (js-indent-line)
+ ;; Any success is ok here.
+ (should t)))
+
(provide 'js-tests)
;;; js-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e52287c: Fix indentation error in js.el,
Tom Tromey <=