Permalink
Browse files

Don't run other checks if continuation is first line in file (#50)

This was causing an infinite loop because GetTrimmedLine was being passed 0.
  • Loading branch information...
1 parent 4a10763 commit a3cb5a2a1bdeab01b190d162305ed4e994331066 @kchmck kchmck committed Oct 7, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 indent/coffee.vim
View
@@ -275,6 +275,12 @@ function! s:GetCoffeeIndent(curlinenum)
" Indent after a continuation if it's the first.
if prevline =~ s:CONTINUATION
let prevprevlinenum = s:GetPrevNormalLine(prevlinenum)
+
+ " If the continuation is the first in the file, don't run the other checks.
+ if !prevprevlinenum
+ return previndent + &shiftwidth
+ endif
+
let prevprevline = s:GetTrimmedLine(prevprevlinenum)
if prevprevline !~ s:CONTINUATION && prevprevline !~ s:CONTINUATION_BLOCK

0 comments on commit a3cb5a2

Please sign in to comment.