Comments should be considered when calculating indentation #74

mcmire opened this Issue Jan 29, 2012 · 4 comments


None yet
2 participants

mcmire commented Jan 29, 2012

Let's say I have this bit of code:

foo = 
  bar: (baz) ->
    # ...

  quux: (plank) ->
    # ...

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

  # 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:

  # 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?


kchmck commented Jan 30, 2012

The reason GetPrevNormalLine skips comments is so it can get at the real code above, but causing this behavior is dumb. How about if the line immediately above is a comment, just take its indentation?

mcmire commented Jan 30, 2012

That sounds good to me.


kchmck commented Jan 31, 2012

Alright, give the latest master a try.

mcmire commented Jan 31, 2012

Yup, that seems to do the trick, not getting that behavior anymore. Thanks muchly!

kchmck closed this Feb 13, 2012

@zoz zoz added a commit to zoz/vim-coffee-script that referenced this issue Feb 16, 2012

@zoz zoz Merge remote-tracking branch 'upstream/master'
* upstream/master: (66 commits)
  Add coffee_linter option
  Replace coffee_make_compiler with coffee_compiler
  Remove unnecessary functions
  Fix a tiny bug in the docs (spotted by pathogen's doc loader)
  Add CoffeeLint command
  Use single quotes
  Update copyrights
  Add coffee_make_compiler to set a compiler path (#78)
  Add support for B in binary literals
  Style tweaks
  detect coffee from shebang line
  Make CoffeeCompile per-buffer instead intead of global (#75)
  If continuing a comment, keep the indent level (#74)
  Don't need to check if less than zero
  Don't wrap GetCoffeeIndent
  Retain indentation level of previous line.
  Fix infinite loop with # at end of line (#67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment