jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
373 stars 67 forks source link

Indentation breaks on first line of file #78

Closed purcell closed 7 years ago

purcell commented 8 years ago

Given

|
module Foo where
...

where | denotes point, indentation raises an error:

Debugger entered: ((cl-assertion-failed (<= start end) nil))
  cl--assertion-failed((<= start end))
  elm-indent-in-comment(2 1)
  elm-indent-indentation-info()
  elm-indent-cycle()
  indent-for-tab-command(nil)
  funcall-interactively(indent-for-tab-command nil)
  #<subr call-interactively>(indent-for-tab-command nil nil)
  ad-Advice-call-interactively(#<subr call-interactively> indent-for-tab-command nil nil)
  apply(ad-Advice-call-interactively #<subr call-interactively> (indent-for-tab-command nil nil))
  call-interactively(indent-for-tab-command nil nil)
  command-execute(indent-for-tab-command)

This appears to be because - in elm-indent-indentation-info, elm-indent-start-of-def returns a position greater than (point). Not obvious to me what the most correct fix for this would be, sorry.

HParker commented 7 years ago

I am not able to replicate this issue.

I have a module

|
module Card exposing(..)

import Html exposing (Html, Attribute, text, div, input, span)
...

for me, with my cursor at the m in module, I don't get an error.

changing the new elm exposing(..) syntax to where also doesn't raise an error.

Are you still experiencing this issue?

purcell commented 7 years ago

Thanks for the comment! That's not quite the case I described, though: cursor should be on the empty leading line. And then, yes, the error is still present for me.

HParker commented 7 years ago

Ah, thanks! I thought that was meant as a downward arrow. I see it as well now.

purcell commented 7 years ago

Yay, great. Thanks.