kchmck/vim-coffee-script — Issue #74: Comments should be considered when calculating indentation
Author: mcmire
Created: 2012-01-29 07:58:07+00:00
State: open

Let's say I have this bit of code:

~~~ coffee-script
foo =
bar: (baz) ->
# ...

quux: (plank) ->
# ...
~~~

Now, let's say I want to add some documentation to the `quux` method. So I start writing:

~~~ coffee-script
# The quux method does this and that .......
quux: (plank) ->
# ...
~~~

and then I press Enter. I'd expect the indentation level to match up with the line I just wrote. Instead, it seems to ignore that and go with the defined indentation level after a `->` line:

~~~ coffee-script
# The quux method does this and that .......
# <-- cursor is now here, which would be technically correct if the above line wasn't present
quux: (plank) ->
# ...
~~~

This really doesn't seem right, and it's actually rather annoying. I see this is intentional, though, as `GetCoffeeIndent` calls `GetTrimmedLine` which excludes comment lines. Is there a reason for this?