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 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.

0 comments on commit 2a691d9

Please sign in to comment.