hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

Indenting inside bad Scala code triggers debugger #78

Closed mcandre closed 10 years ago

mcandre commented 10 years ago

I pressed TAB, trying to indent inside an else, when I had forgotten to close my if, triggering a debugger error in Emacs.

Scala code:

      if (content == "") {
        acc
        else
        [cursor]TAB

Trace:

Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely" 529 529)
  scan-sexps(530 -1)
  scala-syntax:backward-sexp()
  scala-syntax:search-backward-sexp("\\<if\\>")
  scala-indent:goto-forms-align-anchor(nil)
  scala-indent:apply-indent-rules(((scala-indent:goto-forms-align-anchor scala-indent:resolve-forms-align-step) (scala-indent:goto-list-anchor scala-indent:resolve-list-step) (scala-indent:goto-body-anchor scala-indent:resolve-body-step) (scala-indent:goto-run-on-anchor scala-indent:resolve-run-on-step) (scala-indent:goto-block-anchor scala-indent:resolve-block-step)))
  scala-indent:apply-indent-rules(((scala-indent:goto-for-enumerators-anchor scala-indent:resolve-list-step) (scala-indent:goto-forms-align-anchor scala-indent:resolve-forms-align-step) (scala-indent:goto-list-anchor scala-indent:resolve-list-step) (scala-indent:goto-body-anchor scala-indent:resolve-body-step) (scala-indent:goto-run-on-anchor scala-indent:resolve-run-on-step) (scala-indent:goto-block-anchor scala-indent:resolve-block-step)))
  scala-indent:apply-indent-rules(((scala-indent:goto-open-parentheses-anchor scala-indent:resolve-open-parentheses-step) (scala-indent:goto-for-enumerators-anchor scala-indent:resolve-list-step) (scala-indent:goto-forms-align-anchor scala-indent:resolve-forms-align-step) (scala-indent:goto-list-anchor scala-indent:resolve-list-step) (scala-indent:goto-body-anchor scala-indent:resolve-body-step) (scala-indent:goto-run-on-anchor scala-indent:resolve-run-on-step) (scala-indent:goto-block-anchor scala-indent:resolve-block-step)))
  scala-indent:apply-indent-rules(((scala-indent:goto-line-comment-anchor 0) (scala-indent:goto-open-parentheses-anchor scala-indent:resolve-open-parentheses-step) (scala-indent:goto-for-enumerators-anchor scala-indent:resolve-list-step) (scala-indent:goto-forms-align-anchor scala-indent:resolve-forms-align-step) (scala-indent:goto-list-anchor scala-indent:resolve-list-step) (scala-indent:goto-body-anchor scala-indent:resolve-body-step) (scala-indent:goto-run-on-anchor scala-indent:resolve-run-on-step) (scala-indent:goto-block-anchor scala-indent:resolve-block-step)) nil)
  scala-indent:calculate-indent-for-line()
  scala-indent:indent-code-line(nil)
  scala-indent:indent-line()
  indent-for-tab-command(nil)
  call-interactively(indent-for-tab-command nil nil)

System:

hvesalai commented 10 years ago

It will do this only if you have enabled toggle-debug-on-error. It should not be enabled by default in any sane setup, so please check your configs.

mcandre commented 10 years ago

Ah, understood.

My own configuration isn't doing this intentionally.

https://github.com/mcandre/dotfiles/blob/master/.emacs

Maybe one of the packages I use does this?