diff options
| -rw-r--r-- | lisp/progmodes/js.el | 4 | ||||
| -rw-r--r-- | test/lisp/progmodes/js-tests.el | 26 |
2 files changed, 28 insertions, 2 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 54df3913fc6..2e5c6ae119b 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -1720,10 +1720,10 @@ This performs fontification according to `js--class-styles'." | |||
| 1720 | ;; Distinguish /-division from /-regexp chars (and from /-comment-starter). | 1720 | ;; Distinguish /-division from /-regexp chars (and from /-comment-starter). |
| 1721 | ;; FIXME: Allow regexps after infix ops like + ... | 1721 | ;; FIXME: Allow regexps after infix ops like + ... |
| 1722 | ;; https://developer.mozilla.org/en/JavaScript/Reference/Operators | 1722 | ;; https://developer.mozilla.org/en/JavaScript/Reference/Operators |
| 1723 | ;; We can probably just add +, -, !, <, >, %, ^, ~, |, &, ?, : at which | 1723 | ;; We can probably just add +, -, <, >, %, ^, ~, ?, : at which |
| 1724 | ;; point I think only * and / would be missing which could also be added, | 1724 | ;; point I think only * and / would be missing which could also be added, |
| 1725 | ;; but need care to avoid affecting the // and */ comment markers. | 1725 | ;; but need care to avoid affecting the // and */ comment markers. |
| 1726 | ("\\(?:^\\|[=([{,:;]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]" | 1726 | ("\\(?:^\\|[=([{,:;|&!]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]" |
| 1727 | (1 (ignore | 1727 | (1 (ignore |
| 1728 | (forward-char -1) | 1728 | (forward-char -1) |
| 1729 | (when (or (not (memq (char-after (match-beginning 0)) '(?\s ?\t))) | 1729 | (when (or (not (memq (char-after (match-beginning 0)) '(?\s ?\t))) |
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index 9bf7258eebe..84749efa45b 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el | |||
| @@ -59,6 +59,32 @@ | |||
| 59 | * Load the inspector's shared head.js for use by tests that need to | 59 | * Load the inspector's shared head.js for use by tests that need to |
| 60 | * open the something or other")))) | 60 | * open the something or other")))) |
| 61 | 61 | ||
| 62 | (ert-deftest js-mode-regexp-syntax () | ||
| 63 | (with-temp-buffer | ||
| 64 | ;; Normally indentation tests are done in manual/indent, but in | ||
| 65 | ;; this case we are specifically testing a case where the bug | ||
| 66 | ;; caused the indenter not to do anything, and manual/indent can | ||
| 67 | ;; only be used for already-correct files. | ||
| 68 | (insert "function f(start, value) { | ||
| 69 | if (start - 1 === 0 || /[ (:,='\"]/.test(value)) { | ||
| 70 | --start; | ||
| 71 | } | ||
| 72 | if (start - 1 === 0 && /[ (:,='\"]/.test(value)) { | ||
| 73 | --start; | ||
| 74 | } | ||
| 75 | if (!/[ (:,='\"]/.test(value)) { | ||
| 76 | --start; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | ") | ||
| 80 | (js-mode) | ||
| 81 | (indent-region (point-min) (point-max)) | ||
| 82 | (goto-char (point-min)) | ||
| 83 | (dolist (x '(0 4 8 4 4 8 4 4 8 4 0)) | ||
| 84 | (back-to-indentation) | ||
| 85 | (should (= (current-column) x)) | ||
| 86 | (forward-line)))) | ||
| 87 | |||
| 62 | (provide 'js-tests) | 88 | (provide 'js-tests) |
| 63 | 89 | ||
| 64 | ;;; js-tests.el ends here | 90 | ;;; js-tests.el ends here |