Browse files

Retain indentation level of previous line.

Before, if GetCoffeeIndent didn't detect the need to indent / outdent,
it would return -1. Now it returns the indentation level of the previous
line if it exists. This makes for more convenient behavior when typing
'cc' on an empty line below an indented line, and matches how other
vim extensions such as javascript behave.
  • Loading branch information...
1 parent 2591fef commit 2a691d9f5db30d8a44704351401087ad00460825 @nathansobo nathansobo committed Jan 12, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 indent/coffee.vim
@@ -333,8 +333,12 @@ function! s:GetCoffeeIndent(curlinenum)
- " Keep the current indent.
- return -1
+ " If no indent / outdent is needed, keep the indentation level of the previous line if possible
+ if previndent
+ return previndent
+ else
+ return -1
+ endif
" Wrap s:GetCoffeeIndent to keep the cursor position.

2 comments on commit 2a691d9

This introduced an annoying side-effect. When you add or open a line in a comment block the new line is indented. Example

# four score
  # and seven years ago

kchmck replied Jan 30, 2012

Thanks for letting me know. I'm working on a fix.

Please sign in to comment.