@@ -14,7 +14,8 @@ CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, comb
1414 base : CodeMirror . startState ( base ) ,
1515 overlay : CodeMirror . startState ( overlay ) ,
1616 basePos : 0 , baseCur : null ,
17- overlayPos : 0 , overlayCur : null
17+ overlayPos : 0 , overlayCur : null ,
18+ lineSeen : null
1819 } ;
1920 } ,
2021 copyState : function ( state ) {
@@ -27,6 +28,12 @@ CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, comb
2728 } ,
2829
2930 token : function ( stream , state ) {
31+ if ( stream . sol ( ) || stream . string != state . lineSeen ||
32+ Math . min ( state . basePos , state . overlayPos ) < stream . start ) {
33+ state . lineSeen = stream . string ;
34+ state . basePos = state . overlayPos = stream . start ;
35+ }
36+
3037 if ( stream . start == state . basePos ) {
3138 state . baseCur = base . token ( stream , state . base ) ;
3239 state . basePos = stream . pos ;
@@ -37,7 +44,6 @@ CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, comb
3744 state . overlayPos = stream . pos ;
3845 }
3946 stream . pos = Math . min ( state . basePos , state . overlayPos ) ;
40- if ( stream . eol ( ) ) state . basePos = state . overlayPos = 0 ;
4147
4248 if ( state . overlayCur == null ) return state . baseCur ;
4349 if ( state . baseCur != null && combine ) return state . baseCur + " " + state . overlayCur ;
0 commit comments