branch: elpa/web-mode commit 7ad06cafeccdb81840a31cf68ff99a540471c478 Author: fxbois <fxb...@gmail.com> Commit: fxbois <fxb...@gmail.com>
fix indent with else #1160 --- issues/1160.html | 13 +++++++++---- web-mode.el | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/issues/1160.html b/issues/1160.html index 156651569e..7561991d5a 100644 --- a/issues/1160.html +++ b/issues/1160.html @@ -1,10 +1,15 @@ <script> if (cond) + { + code_block(); + } + else { - code_block(); + } + for (i in array) - { - code_block(); - } + { + code_block(); + } </script> diff --git a/web-mode.el b/web-mode.el index 9b2a8b5225..3284b429a6 100644 --- a/web-mode.el +++ b/web-mode.el @@ -8845,6 +8845,11 @@ Also return non-nil if it is the command `self-insert-command' is remapped to." (not (string-match-p "^{" curr-line))) (setq offset (+ prev-indentation web-mode-code-indent-offset)) ) + ((and (string-match-p "else$" prev-line) + (string-match-p "^{" curr-line) + web-mode-enable-curly-brace-indentation) + (setq offset (+ prev-indentation web-mode-code-indent-offset)) + ) ((setq tmp (web-mode-part-is-opener prev-pos reg-beg)) ;;(message "is-opener") (if (or (not (looking-at-p "{")) ;; #1020, #1053, #1160