Fix two js indentation problems
Fix intentation problems reported in https://github.com/mooz/js2-mode/issues/463. * lisp/progmodes/js.el (js--continued-expression-p): Check syntax state after /. (js--multi-line-declaration-indentation): Check syntax state before "const".
This commit is contained in:
parent
b8cf159bbc
commit
e562356c3f
2 changed files with 24 additions and 6 deletions
|
@ -1834,10 +1834,15 @@ This performs fontification according to `js--class-styles'."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(if (js--looking-at-operator-p)
|
(if (js--looking-at-operator-p)
|
||||||
(or (not (memq (char-after) '(?- ?+)))
|
(if (eq (char-after) ?/)
|
||||||
(progn
|
(prog1
|
||||||
(forward-comment (- (point)))
|
(not (nth 3 (syntax-ppss (1+ (point)))))
|
||||||
(not (memq (char-before) '(?, ?\[ ?\()))))
|
(forward-char -1))
|
||||||
|
(or
|
||||||
|
(not (memq (char-after) '(?- ?+)))
|
||||||
|
(progn
|
||||||
|
(forward-comment (- (point)))
|
||||||
|
(not (memq (char-before) '(?, ?\[ ?\())))))
|
||||||
(and (js--find-newline-backward)
|
(and (js--find-newline-backward)
|
||||||
(progn
|
(progn
|
||||||
(skip-chars-backward " \t")
|
(skip-chars-backward " \t")
|
||||||
|
@ -1972,8 +1977,12 @@ statement spanning multiple lines; otherwise, return nil."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(when (not (looking-at js--declaration-keyword-re))
|
(when (not (looking-at js--declaration-keyword-re))
|
||||||
(when (looking-at js--indent-operator-re)
|
(let ((pt (point)))
|
||||||
(goto-char (match-end 0)))
|
(when (looking-at js--indent-operator-re)
|
||||||
|
(goto-char (match-end 0)))
|
||||||
|
;; The "operator" is probably a regexp literal opener.
|
||||||
|
(when (nth 3 (syntax-ppss))
|
||||||
|
(goto-char pt)))
|
||||||
(while (and (not at-opening-bracket)
|
(while (and (not at-opening-bracket)
|
||||||
(not (bobp))
|
(not (bobp))
|
||||||
(let ((pos (point)))
|
(let ((pos (point)))
|
||||||
|
|
|
@ -7,6 +7,9 @@ let c = 1,
|
||||||
var e = 100500,
|
var e = 100500,
|
||||||
+ 1;
|
+ 1;
|
||||||
|
|
||||||
|
// Don't misinterpret "const"
|
||||||
|
/const/
|
||||||
|
|
||||||
function test ()
|
function test ()
|
||||||
{
|
{
|
||||||
return /[/]/.test ('/') // (bug#19397)
|
return /[/]/.test ('/') // (bug#19397)
|
||||||
|
@ -135,6 +138,12 @@ if (1) {
|
||||||
: 4
|
: 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regexp is not a continuation
|
||||||
|
bar(
|
||||||
|
"string arg1",
|
||||||
|
/abc/
|
||||||
|
)
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// indent-tabs-mode: nil
|
// indent-tabs-mode: nil
|
||||||
// js-indent-level: 2
|
// js-indent-level: 2
|
||||||
|
|
Loading…
Add table
Reference in a new issue