File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 5353
5454 if ( stream . peek ( ) == "{" ) {
5555 xmlMode . skipAttribute ( cx . state )
56- state . context = new Context ( CodeMirror . startState ( jsMode , flatXMLIndent ( cx . state ) ) ,
56+
57+ var indent = flatXMLIndent ( cx . state ) , xmlContext = cx . state . context
58+ // If JS starts on same line as tag
59+ if ( xmlContext && stream . string . slice ( 0 , stream . pos ) . match ( / > \s * $ / ) ) {
60+ while ( xmlContext . prev && ! xmlContext . startOfLine )
61+ xmlContext = xmlContext . prev
62+ // If tag starts the line, use XML indentation level
63+ if ( xmlContext . startOfLine ) indent -= config . indentUnit
64+ // Else use JS indentation level
65+ else if ( cx . prev . state . lexical ) indent = cx . prev . state . lexical . indented
66+ // Else if inside of tag
67+ } else if ( cx . depth == 1 ) {
68+ indent += config . indentUnit
69+ }
70+
71+ state . context = new Context ( CodeMirror . startState ( jsMode , indent ) ,
5772 jsMode , 0 , state . context )
5873 return null
5974 }
Original file line number Diff line number Diff line change 5757 MT ( "indent_js" ,
5858 "([bracket&tag <][tag foo][bracket&tag >]" ,
5959 " [bracket&tag <][tag bar] [attribute baz]={[keyword function]() {" ,
60- " [keyword return] [number 10]" ,
61- " }}[bracket&tag />]" ,
60+ " [keyword return] [number 10]" ,
61+ " }}[bracket&tag />]" ,
6262 " [bracket&tag </][tag foo][bracket&tag >])" )
6363
6464 MT ( "spread" ,
You can’t perform that action at this time.
0 commit comments