Skip to content

Commit 4cee17c

Browse files
committed
Convert to guard clause
1 parent a75ce5f commit 4cee17c

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

Diff for: autoload/elixir/indent.vim

+24-30
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ function! s:prev_starts_with(context, expr)
6767
endfunction
6868

6969
function! s:in_embedded_view()
70-
if line(".") =~ '\s\+\~\%\(e\|E\|L\|H\)"""'
71-
return 0
72-
endif
73-
7470
let groups = map(synstack(line('.'), col('.')), "synIDattr(v:val, 'name')")
7571
for group in ['elixirPhoenixESigil', 'elixirLiveViewSigil', 'elixirSurfaceSigil']
7672
if index(groups, group) >= 0
@@ -372,35 +368,33 @@ function! s:do_handle_pattern_match_block(relative_line, context)
372368
endfunction
373369

374370
function! elixir#indent#handle_inside_embedded_view(context)
375-
if s:in_embedded_view()
376-
let pair_lnum = searchpair('<[^\/%].*\%\(\/>\)\@<!$', '', '<\/.*[^%]>$', 'bw', "line('.') == ".a:context.lnum." || s:is_string_or_comment(line('.'), col('.'))", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
377-
378-
if pair_lnum
379-
if a:context.text =~ '<[^\/%].*>.*<\/.*[^\/%]>$'
380-
call s:debug("open and close tags are on the same line")
381-
return indent(pair_lnum) + s:sw()
382-
elseif a:context.text =~ '<\/.\+ \/>'
383-
call s:debug("self-closing tag")
384-
return indent(pair_lnum)
385-
elseif a:context.text =~ '^\s\+>$'
386-
call s:debug("a lone >")
387-
return indent(pair_lnum)
388-
elseif a:context.text =~ '<\/.*[^%]>'
389-
call s:debug("a close tag")
390-
return indent(pair_lnum)
391-
elseif s:prev_ends_with(a:context, ',')
392-
call s:debug("multiline")
393-
return indent(pair_lnum) + 2 * s:sw()
394-
else
395-
call s:debug("normal")
396-
return indent(pair_lnum) + s:sw()
397-
endif
371+
if !s:in_embedded_view()
372+
return -1
373+
endif
374+
375+
let pair_lnum = searchpair('<[^\/%].*\%\(\/>\)\@<!$', '', '<\/.*[^%]>$', 'bw', "line('.') == ".a:context.lnum." || s:is_string_or_comment(line('.'), col('.'))", max([0, a:context.lnum - g:elixir_indent_max_lookbehind]))
376+
if pair_lnum
377+
if a:context.text =~ '<[^\/%].*>.*<\/.*[^\/%]>$'
378+
call s:debug("open and close tags are on the same line")
379+
return indent(pair_lnum) + s:sw()
380+
elseif a:context.text =~ '<\/.\+ \/>'
381+
call s:debug("self-closing tag")
382+
return indent(pair_lnum)
383+
elseif a:context.text =~ '^\s\+>$'
384+
call s:debug("a lone >")
385+
return indent(pair_lnum)
386+
elseif a:context.text =~ '<\/.*[^%]>'
387+
call s:debug("a close tag")
388+
return indent(pair_lnum)
389+
elseif s:prev_ends_with(a:context, ',')
390+
call s:debug("multiline")
391+
return indent(pair_lnum) + 2 * s:sw()
398392
else
399-
call s:debug("no lnum")
400-
return indent(a:context.lnum)
393+
return -1
401394
endif
402395
else
403-
return -1
396+
call s:debug("no lnum")
397+
return indent(a:context.lnum)
404398
endif
405399
endfunction
406400

0 commit comments

Comments
 (0)