3434 endfunction
3535endif
3636
37+ let s: starttag = ' ^\s*<'
3738let s: endtag = ' ^\s*\/\?>\s*;\='
3839let s: real_endtag = ' \s*<\/\+[A-Za-z]*>'
3940
@@ -65,7 +66,7 @@ function! s:syn_jsx_block_end(syns)
6566 \ s: syn_attr_jsx (get (a: syns , -2 ))
6667endfunction
6768
68- function ! s: syn_jsx_depth (syns)
69+ function ! s: syn_jsx_region (syns)
6970 return len (filter (copy (a: syns ), ' v:val ==# "jsxRegion"' ))
7071endfunction
7172
@@ -86,8 +87,8 @@ function! s:syn_jsx_escapejs(syns)
8687endfunction
8788
8889function ! s: syn_jsx_continues (cursyn, prevsyn)
89- let curdepth = s: syn_jsx_depth (a: cursyn )
90- let prevdepth = s: syn_jsx_depth (a: prevsyn )
90+ let curdepth = s: syn_jsx_region (a: cursyn )
91+ let prevdepth = s: syn_jsx_region (a: prevsyn )
9192
9293 return prevdepth == curdepth ||
9394 \ (prevdepth == curdepth + 1 && get (a: cursyn , -1 ) == # ' jsxRegion' )
@@ -113,15 +114,22 @@ function! GetJsxIndent()
113114 " <div | <div
114115 " hoge={ | hoge={
115116 " <div></div> | ##<div></div>
116- if s: syn_jsx_escapejs (prevsyn) && ! (getline (v: lnum - 1 ) = ~? ' }' ) && getline (v: lnum - 1 ) = ~? ' {'
117+ if s: syn_jsx_escapejs (prevsyn) && ! (getline (v: lnum - 1 ) = ~? ' }' )
118+ \& & getline (v: lnum - 1 ) = ~? ' {'
119+ let ind = ind + s: sw ()
120+ endif
121+
122+ if getline (v: lnum ) = ~? s: starttag
123+ \& & getline (v: lnum ) = ~? ' }' && getline (v: lnum ) = ~? ' {'
117124 let ind = ind + s: sw ()
118125 endif
119126
120127 " <div | <div
121128 " hoge={ | hoge={
122129 " <div></div> | <div></div>
123130 " } | }##
124- if s: syn_jsx_escapejs (cursyn) && getline (v: lnum ) = ~? ' }' && ! (getline (v: lnum ) = ~? ' {' )
131+ if s: syn_jsx_escapejs (cursyn) && getline (v: lnum ) = ~? ' }'
132+ \& & ! (getline (v: lnum ) = ~? ' {' )
125133 let ind = ind - s: sw ()
126134 endif
127135
@@ -133,7 +141,8 @@ function! GetJsxIndent()
133141 let ind = ind - s: sw ()
134142 endif
135143
136- if (s: syn_jsx_else_block (cursyn) || s: syn_js_repeat_braces (cursyn)) && s: syn_jsx_close_tag (prevsyn)
144+ if (s: syn_jsx_else_block (cursyn) || s: syn_js_repeat_braces (cursyn))
145+ \& & s: syn_jsx_close_tag (prevsyn)
137146 let ind = ind - s: sw ()
138147 endif
139148 else
0 commit comments