defunkt / coffee-mode

Emacs Major Mode for CoffeeScript
http://ozmm.org/posts/coffee_mode.html
574 stars 147 forks source link

fix filling of inline and multiline comments #337

Closed cosmicexplorer closed 8 years ago

cosmicexplorer commented 8 years ago

Auto filling was failing in these two cases (| is the position of point):

1) When in a multiline comment (### comment), auto-filling the line resulted in the next line having a # prepended to it; this is fixed by this pr.

Failing case:

###
<some text up to fill-column>|
###

2) When in an inline comment, indentation doesn't work correctly (the # of each line isn't aligned correctly). This fix calls coffee-indent-line so they are aligned correctly.

Failing case:

someFunction someArgument # <comment on function that goes to fill-column>|

Also, coffee-in-comment-p is incorrect, because it checks (syntax-ppss) after moving point, and I would change it to use coffee-get-comment-info, but I don't want to break other things that might rely on it.

syohex commented 8 years ago

And this change breaks two tests. Is there any problem ? And please add test of this PR.

NOTE: CI is not enabled. Because I cannot enable CI of this repository. You can test by make test.

cosmicexplorer commented 8 years ago

The test failures are fixed. I wasn't checking boundaries correctly. I'll add tests for these.

cosmicexplorer commented 8 years ago

The added tests check the behavior described in the initial post here. make test runs without any issues on my end.

syohex commented 8 years ago

I have merged your commits.

BTW. I suppose it is better to squash some commits.

cosmicexplorer commented 8 years ago

Gotcha, I will do that next time.