@@ -216,15 +216,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
216
216
indent : function ( state , textAfter ) {
217
217
if ( state . tokenize != tokenBase && state . tokenize != null || state . typeAtEndOfLine ) return CodeMirror . Pass ;
218
218
var ctx = state . context , firstChar = textAfter && textAfter . charAt ( 0 ) ;
219
+ var closing = firstChar == ctx . type ;
219
220
if ( ctx . type == "statement" && firstChar == "}" ) ctx = ctx . prev ;
220
221
if ( parserConfig . dontIndentStatements )
221
222
while ( ctx . type == "statement" && parserConfig . dontIndentStatements . test ( ctx . info ) )
222
223
ctx = ctx . prev
223
224
if ( hooks . indent ) {
224
- var hook = hooks . indent ( state , ctx , textAfter ) ;
225
+ var hook = hooks . indent ( state , ctx , textAfter , indentUnit , closing ) ;
225
226
if ( typeof hook == "number" ) return hook
226
227
}
227
- var closing = firstChar == ctx . type ;
228
228
var switchBlock = ctx . prev && ctx . prev . info == "switch" ;
229
229
if ( parserConfig . allmanIndentation && / [ { ( ] / . test ( firstChar ) ) {
230
230
while ( ctx . type != "top" && ctx . type != "}" ) ctx = ctx . prev
@@ -631,6 +631,17 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
631
631
'"' : function ( stream , state ) {
632
632
state . tokenize = tokenKotlinString ( stream . match ( '""' ) ) ;
633
633
return state . tokenize ( stream , state ) ;
634
+ } ,
635
+ indent : function ( state , ctx , textAfter , indentUnit , closing ) {
636
+ var firstChar = textAfter && textAfter . charAt ( 0 ) ;
637
+ if ( ( state . prevToken == "}" || state . prevToken == ")" ) && textAfter == "" )
638
+ return state . indented ;
639
+ if ( state . prevToken == "operator" && textAfter != "}" ||
640
+ state . prevToken == "variable" && firstChar == "." ||
641
+ ( state . prevToken == "}" || state . prevToken == ")" ) && firstChar == "." )
642
+ return indentUnit * 2 + ctx . indented ;
643
+ if ( ctx . align && ctx . type == "}" )
644
+ return ctx . indented + ( closing ? 0 : indentUnit ) ;
634
645
}
635
646
} ,
636
647
modeProps : { closeBrackets : { triples : '"' } }
0 commit comments