@@ -88,11 +88,19 @@ CodeMirror.validate = (function() {
8888 return tip ;
8989 }
9090
91- function updateLinting ( cm ) {
91+ function startLinting ( cm ) {
92+ var state = cm . _lintState , options = state . options ;
93+ if ( options . async )
94+ options . getAnnotations ( cm , updateLinting , options ) ;
95+ else
96+ updateLinting ( cm , options . getAnnotations ( cm . getValue ( ) ) ) ;
97+ }
98+
99+ function updateLinting ( cm , annotationsNotSorted ) {
92100 clearMarks ( cm ) ;
93101 var state = cm . _lintState , options = state . options ;
94102
95- var annotations = groupByLine ( options . getAnnotations ( cm . getValue ( ) ) ) ;
103+ var annotations = groupByLine ( annotationsNotSorted ) ;
96104
97105 for ( var line = 0 ; line < annotations . length ; ++ line ) {
98106 var anns = annotations [ line ] ;
@@ -124,7 +132,7 @@ CodeMirror.validate = (function() {
124132 function onChange ( cm ) {
125133 var state = cm . _lintState ;
126134 clearTimeout ( state . timeout ) ;
127- state . timeout = setTimeout ( function ( ) { updateLinting ( cm ) ; } , state . options . delay || 500 ) ;
135+ state . timeout = setTimeout ( function ( ) { startLinting ( cm ) ; } , state . options . delay || 500 ) ;
128136 }
129137
130138 function popupSpanTooltip ( ann , e ) {
@@ -168,7 +176,7 @@ CodeMirror.validate = (function() {
168176 var state = cm . _lintState = new LintState ( cm , parseOptions ( val ) , hasLintGutter ) ;
169177 cm . on ( "change" , onChange ) ;
170178 CodeMirror . on ( cm . getWrapperElement ( ) , "mouseover" , state . onMouseOver ) ;
171- updateLinting ( cm ) ;
179+ startLinting ( cm ) ;
172180 }
173181 } ) ;
174182} ) ( ) ;
0 commit comments