@@ -372,36 +372,45 @@ function! elixir#indent#handle_inside_embedded_view(context)
372
372
return -1
373
373
endif
374
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 ]))
375
+ " Multi-line opening tag -- >, />, or %> are on a different line that their opening <
376
+ let pair_lnum = searchpair (' ^\s\+<.*[^>]$' , ' ' , ' ^[^<]*[/%]\?>$' , ' bW' , " line('.') == " .a: context .lnum." || s:is_string_or_comment(line('.'), col('.'))" , max ([0 , a: context .lnum - g: elixir_indent_max_lookbehind ]))
376
377
if pair_lnum
377
- if a: context .text = ~ ' <[^\/%].*>.*<\/.*[^\/%]> $'
378
- call s: debug (" open and close tags are on the same line " )
378
+ if a: context .text = ~ ' ^\s\+\%\(>\|\/>\|%>\) $'
379
+ call s: debug (" current line is alone >, />, or %> " )
379
380
return indent (pair_lnum)
380
- elseif a: context .text = ~ ' <\/.*[^%\/]>'
381
- call s: debug (" a close 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 .prev_nb_text = ~ ' \s\+<[^%\/].*>$'
387
- call s: debug (" single open tag" )
388
- return indent (pair_lnum) + s: sw ()
389
- elseif a: context .prev_nb_text = ~ ' \s\+<[^%\/].*[^>]$'
390
- call s: debug (" multiline opening tag" )
381
+ elseif a: context .text = ~ ' \%\(>\|\/>\|%>\)$'
382
+ call s: debug (" current line ends in >, />, or %>" )
383
+ return -1
384
+ else
385
+ call s: debug (" in the body of a multi-line opening tag" )
391
386
return indent (pair_lnum) + s: sw ()
392
- elseif s: prev_ends_with (a: context , ' ,' )
393
- call s: debug (" multiline opening eex" )
394
- return indent (pair_lnum)
395
- elseif a: context .text = ~ ' <\/.\+ \/>'
396
- call s: debug (" self-closing tag" )
387
+ endif
388
+ endif
389
+
390
+ " Special cases
391
+ " if s:prev_ends_with(a:context, '^\s\+\/>\|<\/.*>')
392
+ if s: prev_ends_with (a: context , ' ^[^<]*\/>' )
393
+ call s: debug (" prev line is closing a multi-line self-closing tag" )
394
+ return indent (a: context .prev_nb_lnum) - s: sw ()
395
+ elseif s: prev_ends_with (a: context , ' \/>\|<\/\w\+>' )
396
+ call s: debug (" prev line is any other kind of closing tag" )
397
+ return indent (a: context .prev_nb_lnum)
398
+ elseif s: prev_ends_with (a: context , ' ^\s\+>' )
399
+ call s: debug (" prev line is a single >" )
400
+ return indent (a: context .prev_nb_lnum) + s: sw ()
401
+ endif
402
+
403
+ " Regular old HTML
404
+ let pair_lnum = searchpair (' ^\s\+<[^%\/].*[^/]>$' , ' ' , ' ^\s\+<\/\w\+>$' , ' bW' , " line('.') == " .a: context .lnum." || s:is_string_or_comment(line('.'), col('.'))" , max ([0 , a: context .lnum - g: elixir_indent_max_lookbehind ]))
405
+ if pair_lnum
406
+ if a: context .text = ~ ' ^\s\+<\/\w\+>$'
397
407
return indent (pair_lnum)
398
408
else
399
- call debug (" normal" )
400
- return -2
409
+ return indent (pair_lnum) + s: sw ()
401
410
endif
402
- else
403
- return -1
404
411
endif
412
+
413
+ return -1
405
414
endfunction
406
415
407
416
function ! elixir#indent#handle_inside_generic_block (context)
0 commit comments