Skip to content

Commit 6e92143

Browse files
committed
add in backtracking
1 parent a5302e0 commit 6e92143

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

indent/haskell.vim

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,20 @@ function! GetHaskellIndent()
449449
" y = 2
450450
" >in x + 1
451451
if l:line =~ '\C^\s*\<in\>'
452-
return match(l:prevline, '\S') - (4 - g:haskell_indent_in)
452+
let l:s = 0
453+
let l:c = v:lnum - 1
454+
455+
while l:s <= 0 && l:c >= 1
456+
let l:l = getline(l:c)
457+
let l:s = match(l:l, '\C\<let\>')
458+
if l:s >= 1 && s:isSYN('haskellLet', l:c, l:s + 1)
459+
break
460+
elseif l:l =~ '^\S'
461+
return -1
462+
endif
463+
let l:c -= 1
464+
endwhile
465+
return l:s + g:haskell_indent_in
453466
endif
454467

455468
" data Foo

tests/indent/test018/expected.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let foo = 1
2+
bar = baz
3+
quux
4+
in

tests/indent/test018/test.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let foo = 1
2+
bar = baz
3+
quux
4+
in

tests/indent/test018/test.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
G==
2+
:saveas! result.hs
3+
:q!

0 commit comments

Comments
 (0)