@@ -3431,11 +3431,11 @@ window.CodeMirror = (function() {
34313431 span . marker . attachLine ( line ) ;
34323432 }
34333433
3434- function markedSpansBefore ( old , startCh ) {
3434+ function markedSpansBefore ( old , startCh , isInsert ) {
34353435 if ( old ) for ( var i = 0 , nw ; i < old . length ; ++ i ) {
34363436 var span = old [ i ] , marker = span . marker ;
34373437 var startsBefore = span . from == null || ( marker . inclusiveLeft ? span . from <= startCh : span . from < startCh ) ;
3438- if ( startsBefore || marker . type == "bookmark" && span . from == startCh ) {
3438+ if ( startsBefore || marker . type == "bookmark" && span . from == startCh && ( ! isInsert || ! span . marker . insertLeft ) ) {
34393439 var endsAfter = span . to == null || ( marker . inclusiveRight ? span . to >= startCh : span . to > startCh ) ;
34403440 ( nw || ( nw = [ ] ) ) . push ( { from : span . from ,
34413441 to : endsAfter ? null : span . to ,
@@ -3445,11 +3445,11 @@ window.CodeMirror = (function() {
34453445 return nw ;
34463446 }
34473447
3448- function markedSpansAfter ( old , startCh , endCh ) {
3448+ function markedSpansAfter ( old , endCh , isInsert ) {
34493449 if ( old ) for ( var i = 0 , nw ; i < old . length ; ++ i ) {
34503450 var span = old [ i ] , marker = span . marker ;
34513451 var endsAfter = span . to == null || ( marker . inclusiveRight ? span . to >= endCh : span . to > endCh ) ;
3452- if ( endsAfter || marker . type == "bookmark" && span . from == endCh && span . from != startCh ) {
3452+ if ( endsAfter || marker . type == "bookmark" && span . from == endCh && ( ! isInsert || span . marker . insertLeft ) ) {
34533453 var startsBefore = span . from == null || ( marker . inclusiveLeft ? span . from <= endCh : span . from < endCh ) ;
34543454 ( nw || ( nw = [ ] ) ) . push ( { from : startsBefore ? null : span . from - endCh ,
34553455 to : span . to == null ? null : span . to - endCh ,
@@ -3464,10 +3464,10 @@ window.CodeMirror = (function() {
34643464 var oldLast = isLine ( doc , change . to . line ) && getLine ( doc , change . to . line ) . markedSpans ;
34653465 if ( ! oldFirst && ! oldLast ) return null ;
34663466
3467- var startCh = change . from . ch , endCh = change . to . ch ;
3467+ var startCh = change . from . ch , endCh = change . to . ch , isInsert = posEq ( change . from , change . to ) ;
34683468 // Get the spans that 'stick out' on both sides
3469- var first = markedSpansBefore ( oldFirst , startCh ) ;
3470- var last = markedSpansAfter ( oldLast , change . from . line == change . to . line ? startCh : NaN , endCh ) ;
3469+ var first = markedSpansBefore ( oldFirst , startCh , isInsert ) ;
3470+ var last = markedSpansAfter ( oldLast , endCh , isInsert ) ;
34713471
34723472 // Next, merge those two ends
34733473 var sameLine = change . text . length == 1 , offset = lst ( change . text ) . length + ( sameLine ? startCh : 0 ) ;
@@ -4267,9 +4267,11 @@ window.CodeMirror = (function() {
42674267 markText : function ( from , to , options ) {
42684268 return markText ( this , clipPos ( this , from ) , clipPos ( this , to ) , options , "range" ) ;
42694269 } ,
4270- setBookmark : function ( pos , widget ) {
4270+ setBookmark : function ( pos , options ) {
4271+ var realOpts = { replacedWith : options && ( options . nodeType == null ? options . widget : options ) ,
4272+ insertLeft : options && options . insertLeft } ;
42714273 pos = clipPos ( this , pos ) ;
4272- return markText ( this , pos , pos , widget ? { replacedWith : widget } : { } , "bookmark" ) ;
4274+ return markText ( this , pos , pos , realOpts , "bookmark" ) ;
42734275 } ,
42744276 findMarksAt : function ( pos ) {
42754277 pos = clipPos ( this , pos ) ;
0 commit comments