@@ -63,7 +63,7 @@ if !exists('g:purescript_indent_dot')
6363endif
6464
6565setlocal indentexpr = GetPurescriptIndent ()
66- setlocal indentkeys = ! ^F,o ,O,},= where,= in ,= ::,= - >,= →,== >,= ⇒
66+ setlocal indentkeys = ! ^F,o ,O,},= where,= in ,= ::,= - >,= →,== >,= ⇒, = else
6767
6868function ! s: GetSynStack (lnum, col )
6969 return map (synstack (a: lnum , a: col ), { key , val - > synIDattr (val, " name" ) })
@@ -199,17 +199,18 @@ function! GetPurescriptIndent()
199199 return match (prevline, ' \<let\>' ) + g: purescript_indent_let
200200 endif
201201
202- let s = match (prevline, ' \<else\>' )
203- if s >= 0 && index (s: GetSynStack (v: lnum - 1 , s ), ' purescriptString' ) == -1
204- let s = match (prevline, ' \<if\>.*\&.*\zs\<then\>' )
205- if s > 0
206- return s
202+ let s = searchpairpos (' \%(--.\{-}\)\@<!\<if\>' , ' \<then\>' , ' \<else\>.*\zs$' , ' bnrc' )[0 ]
203+ if s > 0
204+ " this rule ensures that using `=` in visual mode will correctly indent
205+ " `if then else`, but it does not handle lines after `then` and `else`
206+ if line = ~ ' \<\%(then\|else\)\>'
207+ return match (getline (s ), ' \<if\>' ) + &l: shiftwidth
207208 endif
209+ endif
208210
209- let s = match (prevline, ' \<if\>' )
210- if s > 0
211- return s + g: purescript_indent_if
212- endif
211+ let p = match (prevline, ' \<if\>\%(.\{-}\<then\>.\{-}\<else\>\)\@!' )
212+ if p > 0
213+ return p + &l: shiftwidth
213214 endif
214215
215216 let s = match (prevline, ' =\s*$' )
0 commit comments