diff options
| author | Dmitry Gutov <dgutov@yandex.ru> | 2016-03-05 14:35:10 +0200 |
|---|---|---|
| committer | Dmitry Gutov <dgutov@yandex.ru> | 2016-03-05 14:35:35 +0200 |
| commit | dc9d837d02edd665f2c9468de51bb4a1dda7ef6d (patch) | |
| tree | c285c7e4df684ae98679577bc55e137c367736d7 /lisp | |
| parent | 792311228d8f4cb26262c279e310b0344d735bd8 (diff) | |
| download | emacs-dc9d837d02edd665f2c9468de51bb4a1dda7ef6d.tar.gz | |
Don't misindent computed property generator methods
* lisp/progmodes/js.el (js--looking-at-operator-p):
Don't misindent computed property generator methods
(https://github.com/mooz/js2-mode/issues/317).
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/js.el | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index d59e7679b47..15a52ba8cdc 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -1758,12 +1758,13 @@ This performs fontification according to `js--class-styles'." (eq (char-after) ??)))) (not (and (eq (char-after) ?*) - (looking-at (concat "\\* *" js--name-re " *(")) + ;; Generator method (possibly using computed property). + (looking-at (concat "\\* *\\(?:\\[\\|" js--name-re " *(\\)")) (save-excursion - (goto-char (1- (match-end 0))) - (let (forward-sexp-function) (forward-sexp)) - (js--forward-syntactic-ws) - (eq (char-after) ?{))))))) + (js--backward-syntactic-ws) + ;; We might misindent some expressions that would + ;; return NaN anyway. Shouldn't be a problem. + (memq (char-before) '(?, ?} ?{)))))))) (defun js--continued-expression-p () "Return non-nil if the current line continues an expression." |
