Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Comments should be considered when calculating indentation #74

Closed
mcmire opened this Issue · 4 comments

2 participants

@mcmire

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
Owner

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

That sounds good to me.

@kchmck
Owner

Alright, give the latest master a try.

@mcmire

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

@kchmck kchmck closed this
@zoz zoz referenced this issue from a commit in zoz/vim-coffee-script
@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
  Dox
  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
  Dox
  Don't wrap GetCoffeeIndent
  Retain indentation level of previous line.
  Docks
  Fix infinite loop with # at end of line (#67)
  ...
df559c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.